static gint timeout (C2NetworkTraffic *nt) { gint current_recv, current_send, record; gint seconds_to_display; /* This is a dynamic value, the * SECONDS_TO_DISPLAY constant * is about how much we WISH to * display, not how much we WILL * display. */ GtkWidget *widget = GTK_WIDGET (nt); seconds_to_display = widget->allocation.width / PIXELS_PER_SECOND; current_recv = c2_net_speed_tracker_recv (); current_send = c2_net_speed_tracker_send (); if (g_slist_length (nt->recv) > seconds_to_display) nt->recv = g_slist_remove_link (nt->recv, g_slist_last (nt->recv)); nt->recv = g_slist_prepend (nt->recv, (gpointer) current_recv); if (g_slist_length (nt->send) > seconds_to_display) nt->send = g_slist_remove_link (nt->send, g_slist_last (nt->send)); nt->send = g_slist_prepend (nt->send, (gpointer) current_send); /* Update the maximum speed */ record = current_send > current_recv ? current_send : current_recv; if (record > nt->top_speed) nt->top_speed = record; else { GSList *l; nt->top_speed = 1024; for (l = nt->send; l; l = g_slist_next (l)) if (GPOINTER_TO_INT (l->data) > nt->top_speed) nt->top_speed = GPOINTER_TO_INT (l->data); for (l = nt->recv; l; l = g_slist_next (l)) if (GPOINTER_TO_INT (l->data) > nt->top_speed) nt->top_speed = GPOINTER_TO_INT (l->data); } /* Time to draw */ draw_background (nt); draw_top_speed (nt); draw_list (nt, nt->send); draw_list (nt, nt->recv); draw_screen (nt); return TRUE; }
static void undo_stack_expunge_oldest (UndoStack *stack) { UndoItem *oldest = g_slist_last (stack->undo_items)->data; stack->undo_items = g_slist_remove (stack->undo_items, oldest); undo_item_destroy (oldest); }
static void last_msg_add(GSList **list, const char *nick, int own, int max) { LAST_MSG_REC *rec; rec = last_msg_find(*list, nick); if (rec != NULL) { /* msg already exists, update it */ *list = g_slist_remove(*list, rec); if (own) rec->own = max; else if (rec->own) rec->own--; } else { rec = g_new(LAST_MSG_REC, 1); rec->nick = g_strdup(nick); if ((int)g_slist_length(*list) == max) { *list = g_slist_remove(*list, g_slist_last(*list)->data); } rec->own = own ? max : 0; } rec->time = time(NULL); last_msg_dec_owns(*list); *list = g_slist_prepend(*list, rec); }
/** * oh_add_resource * @table: Pointer to the RPT to which the RPT entry will be added. * @entry: The RPT entry (resource) to be added to the RPT. * @data: Pointer to private data for storing along with the RPT entry. * @owndata: boolean flag. true (%KEEP_RPT_DATA) to tell the interface *not* * to free the data when the resource is removed. false (%FREE_RPT_DATA) to tell * the interface to free the data when the resource is removed. * * Add a RPT entry to the RPT along with some private data. * If an RPT entry with the same resource id exists int the RPT, it will be * overlayed with the new RPT entry. Also, this function will assign the * resource id as its entry id since it is expected to be unique for the table. * The update count and timestamp will not be updated if the entry being added * already existed in the table and was the same. * * Returns: SA_OK on success Or minus SA_OK on error. SA_ERR_HPI_INVALID_PARAMS will * be returned if @table is NULL, @entry is NULL, ResourceId in @entry equals * SAHPI_FIRST_ENTRY, ResourceId in @entry equals SAHPI_UNSPECIFIED_RESOURCE_ID, * or ResourceEntity in @entry has a malformed entity path (look at the * entity path utils documentation). **/ SaErrorT oh_add_resource(RPTable *table, SaHpiRptEntryT *entry, void *data, int owndata) { RPTEntry *rptentry; int update_info = 0; if (!table) { dbg("ERROR: Cannot work on a null table pointer."); return SA_ERR_HPI_INVALID_PARAMS; } else if (!entry) { dbg("Failed to add. RPT entry is NULL."); return SA_ERR_HPI_INVALID_PARAMS; } else if (entry->ResourceId == SAHPI_FIRST_ENTRY) { dbg("Failed to add. RPT entry needs a resource id before being added"); return SA_ERR_HPI_INVALID_PARAMS; } else if (entry->ResourceId == SAHPI_UNSPECIFIED_RESOURCE_ID) { dbg("Failed to add. RPT entry has an invalid/reserved id assigned. (SAHPI_UNSPECIFIED_RESOURCE_ID)"); return SA_ERR_HPI_INVALID_PARAMS; } else if (!oh_valid_ep(&(entry->ResourceEntity))) { dbg("Failed to add RPT entry. Entity path does not contain root element."); return SA_ERR_HPI_INVALID_PARAMS; } entry->EntryId = entry->ResourceId; /* Check to see if the entry is in the RPTable already */ rptentry = get_rptentry_by_rid(table, entry->ResourceId); /* If not, create new RPTEntry */ if (!rptentry) { rptentry = (RPTEntry *)g_malloc0(sizeof(RPTEntry)); if (!rptentry) { dbg("Not enough memory to add RPT entry."); return SA_ERR_HPI_OUT_OF_MEMORY; } update_info = 1; /* Have a new changed entry */ /* Put new RPTEntry in RPTable */ table->rptlist = g_slist_append(table->rptlist, (gpointer)rptentry); /* Add to rpt hash table */ if (!table->rptable) /* Create hash table if it doesn't exist */ table->rptable = g_hash_table_new(g_int_hash, g_int_equal); rptentry->rpt_entry.EntryId = entry->ResourceId; g_hash_table_insert(table->rptable, &(rptentry->rpt_entry.EntryId), g_slist_last(table->rptlist)); } /* Else, modify existing RPTEntry */ if (rptentry->data && rptentry->data != data && !rptentry->owndata) g_free(rptentry->data); rptentry->data = data; rptentry->owndata = owndata; /* Check if we really have a new/changed entry */ if (update_info || memcmp(entry, &(rptentry->rpt_entry), sizeof(SaHpiRptEntryT))) { update_info = 1; rptentry->rpt_entry = *entry; } if (update_info) update_rptable(table); return SA_OK; }
Task *prev_task(Task *tsk) { if (tsk == 0) return 0; GSList *l0, *lfirst_tsk; Task *tsk1, *tsk2; Taskbar* tskbar = tsk->area.parent; tsk2 = 0; l0 = tskbar->area.children; if (taskbarname_enabled) l0 = l0->next; lfirst_tsk = l0; for (; l0 ; l0 = l0->next) { tsk1 = l0->data; if (tsk1 == tsk) { if (l0 == lfirst_tsk) { l0 = g_slist_last ( l0 ); tsk2 = l0->data; } return tsk2; } tsk2 = tsk1; } return 0; }
static void _tarif_clear(gint tarif_id) { GSList **tarif = NULL; GSList *link = NULL; CCL_tarifpart *tp = NULL; GData *freed = NULL; tarif = g_new0(GSList *, 1); *tarif = g_datalist_id_get_data(&ccl->tarifs, tarif_id); g_assert(NULL != tarif); g_datalist_init(&freed); while ((link = g_slist_last(*tarif)) && *tarif) { *tarif = g_slist_remove_link(*tarif, link); tp = (CCL_tarifpart *) link->data; if (!g_datalist_id_get_data(&freed, GPOINTER_TO_INT(tp->prices))) { g_datalist_clear(tp->prices); g_datalist_id_set_data(&freed, GPOINTER_TO_INT(tp->prices), (void *)tp->prices); g_free(tp->prices); } g_slist_free_1(link); g_free(tp); } g_datalist_clear(&freed); *tarif = NULL; g_datalist_id_remove_data(&ccl->tarifs, tarif_id); g_free(tarif); }
static GTlsCertificate * parse_and_create_certificate (const gchar *data, gsize data_len, const gchar *key_pem, GError **error) { GSList *pem_list; GTlsCertificate *cert; pem_list = parse_and_create_certificate_list (data, data_len, error); if (!pem_list) return NULL; /* We don't pass the error here because, if it fails, we still want to * load and return the first certificate. */ cert = create_certificate_chain_from_list (pem_list, key_pem); if (!cert) { GSList *last = NULL; /* Get the first certificate (which is the last one as the list is * in reverse order). */ last = g_slist_last (pem_list); cert = tls_certificate_new_internal (last->data, key_pem, NULL, error); } g_slist_free_full (pem_list, g_free); return cert; }
void structsInLists(void) { GSList* list = NULL; Person* tom = (Person*)malloc(sizeof(Person)); tom->name = "Tom"; tom->shoe_size = 12; list = g_slist_append(list, tom); Person* fred = g_new(Person, 1); // allocate memory for one Person struct fred->name = "Fred"; fred->shoe_size = 11; list = g_slist_append(list, fred); g_printf("Tom's shoe size is '%d'\n", ((Person*)list->data)->shoe_size); g_printf("The last Person's name is '%s'\n", ((Person*)g_slist_last(list)->data)->name); g_slist_free(list); free(tom); g_free(fred); }
static GSList *compl_dyn_resource_slack(void) { GSList *buddies = buddy_getresources_locale(NULL); GSList *buddies_last = g_slist_last(buddies); GSList *buddy_pointer; buddies = g_slist_append(buddies, g_strdup("@here")); buddies = g_slist_append(buddies, g_strdup("@channel")); buddies = g_slist_append(buddies, g_strdup("@everyone")); for ( buddy_pointer = buddies; ; buddy_pointer = g_slist_next(buddy_pointer) ) { gchar *old_name = buddy_pointer->data; gchar *new_name = g_strdup_printf("@%s", old_name); buddies = g_slist_append(buddies, new_name); if (buddy_pointer == buddies_last) { break; } } return buddies; }
int main(int argc, char** argv) { GSList* list = NULL; Person* tom = (Person*)malloc(sizeof(Person)); tom->name = "Tom"; tom->shoe_size = 10; list = g_slist_append(list, tom); Person* fred = g_new(Person, 1); // allocate memory for one Person struct fred->name = "yred"; fred->shoe_size = 11; list = g_slist_append(list, fred); Person* god = g_new(Person, 1); // allocate memory for one Person struct god->name = "zod"; god->shoe_size = 15; list = g_slist_append(list, god); list = g_slist_sort(list, (GCompareFunc)my_comparator); printf("Tom's shoe size is '%d'\n", ((Person*)list->data)->shoe_size); printf("The last Person's name is '%s'\n", ((Person*)g_slist_last(list)->data)->name); g_slist_free(list); free(tom); g_free(fred); g_free(god); return 0; }
void gn_combo_history_add (GnComboHistory *history, const gchar *text) { GSList *item; g_return_if_fail (GN_IS_COMBO_HISTORY (history)); g_return_if_fail (text != NULL); if ((item = g_slist_find_custom (history->priv->items, (gpointer) text, compare))) { /* item is already in list, remove them */ history->priv->items = g_slist_remove (history->priv->items, item->data); } if (g_slist_length (history->priv->items) >= history->priv->max_history) { item = g_slist_last (history->priv->items); history->priv->items = g_slist_remove (history->priv->items, item->data); } history->priv->items = g_slist_prepend (history->priv->items, g_strdup (text)); gn_combo_history_set_popdown_strings (history); gn_combo_history_settings_save (history); }
/** * oh_create_handler * @handler_config: Hash table containing the configuration for a handler * read from the configuration file. * @hid: pointer where hid of newly created handler will be stored. * * Returns: SA_OK on success. If handler failed to open, then @hid will * contain a valid handler id, but SA_ERR_HPI_INTERNAL_ERROR will be * returned. **/ SaErrorT oh_create_handler (GHashTable *handler_config, unsigned int *hid) { struct oh_handler *handler = NULL; if (!handler_config || !hid) { err("ERROR creating handler. Invalid parameters."); return SA_ERR_HPI_INVALID_PARAMS; } *hid = 0; handler = new_handler(handler_config); if (!handler) return SA_ERR_HPI_ERROR; *hid = handler->id; g_static_rec_mutex_lock(&oh_handlers.lock); oh_handlers.list = g_slist_append(oh_handlers.list, handler); g_hash_table_insert(oh_handlers.table, &(handler->id), g_slist_last(oh_handlers.list)); handler->hnd = handler->abi->open(handler->config, handler->id, &oh_process_q); if (!handler->hnd) { err("A handler #%d on the %s plugin could not be opened.", handler->id, handler->plugin_name); g_static_rec_mutex_unlock(&oh_handlers.lock); return SA_ERR_HPI_INTERNAL_ERROR; } g_static_rec_mutex_unlock(&oh_handlers.lock); return SA_OK; }
static void pidgin_smiley_themes_remove_non_existing(void) { static struct smiley_theme *theme = NULL; GSList *iter = NULL; if (!smiley_themes) return ; for (iter = smiley_themes ; iter ; iter = iter->next) { theme = ((struct smiley_theme *)(iter->data)); if (!g_file_test(theme->path, G_FILE_TEST_EXISTS)) { if (theme == current_smiley_theme) current_smiley_theme = ((struct smiley_theme *)(NULL == iter->next ? NULL : iter->next->data)); pidgin_themes_destroy_smiley_theme(theme); iter->data = NULL; } } /* Remove all elements whose data is NULL */ smiley_themes = g_slist_remove_all(smiley_themes, NULL); if (!current_smiley_theme && smiley_themes) { struct smiley_theme *smile = g_slist_last(smiley_themes)->data; pidgin_themes_load_smiley_theme(smile->path, TRUE); } }
void add_client_serial_mapping (BroadwayClient *client, guint32 client_serial, guint32 daemon_serial) { BroadwaySerialMapping *map; GSList *last; last = g_slist_last (client->serial_mappings); if (last != NULL) { map = last->data; /* If we have no web client, don't grow forever */ if (map->daemon_serial == daemon_serial) { map->client_serial = client_serial; return; } } map = g_new0 (BroadwaySerialMapping, 1); map->client_serial = client_serial; map->daemon_serial = daemon_serial; client->serial_mappings = g_slist_append (client->serial_mappings, map); }
void datastore_put(struct datastore *ds, void *data, unsigned int length, int in_unitsize, int *probelist) { int capacity, stored, size, num_chunks, chunk_bytes_free, chunk_offset; gpointer chunk; if(ds->chunklist == NULL) chunk = new_chunk(&ds); else chunk = g_slist_last(ds->chunklist)->data; num_chunks = g_slist_length(ds->chunklist); capacity = (num_chunks * DATASTORE_CHUNKSIZE); chunk_bytes_free = capacity - (ds->ds_unitsize * ds->num_units); chunk_offset = capacity - (DATASTORE_CHUNKSIZE * (num_chunks - 1)) - chunk_bytes_free; stored = 0; while(stored < length) { if(chunk_bytes_free == 0) { chunk = new_chunk(&ds); chunk_bytes_free = DATASTORE_CHUNKSIZE; chunk_offset = 0; } if(length - stored > chunk_bytes_free) size = chunk_bytes_free; else /* last part, won't fill up this chunk */ size = length - stored; memcpy(chunk + chunk_offset, data + stored, size); chunk_bytes_free -= size; stored += size; } ds->num_units += stored / ds->ds_unitsize; }
static int nick_completion_timeout(void) { GSList *tmp, *link; time_t now; int len; now = time(NULL); for (tmp = servers; tmp != NULL; tmp = tmp->next) { IRC_SERVER_REC *rec = tmp->data; if (!irc_server_check(rec)) continue; len = g_slist_length(rec->lastmsgs); if (len > 0 && len >= settings_get_int("completion_keep_privates")) { link = g_slist_last(rec->lastmsgs); g_free(link->data); rec->lastmsgs = g_slist_remove(rec->lastmsgs, link->data); } } for (tmp = channels; tmp != NULL; tmp = tmp->next) { CHANNEL_REC *rec = tmp->data; nick_completion_remove_old(&rec->lastownmsgs, settings_get_int("completion_keep_ownpublics"), now); nick_completion_remove_old(&rec->lastmsgs, settings_get_int("completion_keep_publics"), now); } return 1; }
static GSList * cc_build_interfaces (GSList *list, IDL_tree tree) { if (!tree) return list; switch (IDL_NODE_TYPE (tree)) { case IDLN_MODULE: list = cc_build_interfaces ( list, IDL_MODULE (tree).definition_list); break; case IDLN_LIST: { IDL_tree sub; for (sub = tree; sub; sub = IDL_LIST (sub).next) list = cc_build_interfaces ( list, IDL_LIST (sub).data); break; } case IDLN_ATTR_DCL: { IDL_tree curitem; for (curitem = IDL_ATTR_DCL (tree).simple_declarations; curitem; curitem = IDL_LIST (curitem).next) { OIDL_Attr_Info *ai = IDL_LIST (curitem).data->data; list = cc_build_interfaces (list, ai->op1); if (ai->op2) list = cc_build_interfaces (list, ai->op2); } break; } case IDLN_INTERFACE: { Interface *i = g_new0 (Interface, 1); i->tree = tree; list = g_slist_append (list, i); list = cc_build_interfaces (list, IDL_INTERFACE(tree).body); break; } case IDLN_OP_DCL: { Interface *i; g_return_val_if_fail (list != NULL, NULL); i = ( g_slist_last(list) )->data; i->methods = g_slist_append (i->methods, tree); break; } case IDLN_EXCEPT_DCL: break; default: break; } return list; }
static inline void slist_regression(const slist_t *slist) { g_assert(g_slist_first(slist->head) == slist->head); g_assert(g_slist_first(slist->tail) == slist->head); g_assert(g_slist_last(slist->head) == slist->tail); g_assert(g_slist_length(slist->head) == (uint) slist->length); }
static SPItem * sp_quick_align_find_master (const GSList *slist, gboolean horizontal) { NRRectF b; const GSList * l; SPItem * master, * item; gdouble dim, max; master = NULL; switch (base) { case SP_ALIGN_LAST: return (SPItem *) slist->data; break; case SP_ALIGN_FIRST: return (SPItem *) g_slist_last ((GSList *) slist)->data; break; case SP_ALIGN_BIGGEST: max = -1e18; for (l = slist; l != NULL; l = l->next) { item = (SPItem *) l->data; sp_item_bbox_desktop (item, &b); if (horizontal) { dim = b.x1 - b.x0; } else { dim = b.y1 - b.y0; } if (dim > max) { max = dim; master = item; } } return master; break; case SP_ALIGN_SMALLEST: max = 1e18; for (l = slist; l != NULL; l = l->next) { item = (SPItem *) l->data; sp_item_bbox_desktop (item, &b); if (horizontal) { dim = b.x1 - b.x0; } else { dim = b.y1 - b.y0; } if (dim < max) { max = dim; master = item; } } return master; break; default: g_assert_not_reached (); break; } return NULL; }
static void go_cmd_context_error_info_list_default (GOCmdContext *gcc, GSList *errs) { if (errs == NULL) go_cmd_context_error_info (gcc, NULL); else go_cmd_context_error_info (gcc, g_slist_last (errs)->data); }
GSList* g_slist_concat (GSList *list1, GSList *list2) { if (!list1) return list2; g_slist_last (list1)->next = list2; return list1; }
static gpointer list_last_data (GSList *lst) { GSList *tail; tail = g_slist_last (lst); return tail->data; }
int main(int argc, char** argv) { GSList* list = g_slist_append(NULL, "Chicago"); list = g_slist_append(list, "Boston"); list = g_slist_append(list, "Albany"); list = g_slist_sort(list, (GCompareFunc)my_comparator); printf("The first item is now '%s'\n", list->data); printf("The last item is now '%s'\n", g_slist_last(list)->data); g_slist_free(list); return 0; }
int main(void) { GSList *list = g_slist_append(NULL, "Chicago"); list = g_slist_append(list, "Boston"); list = g_slist_append(list, "London"); list = g_slist_sort(list, (GCompareFunc)my_comparator); printf("First item is %s\n" "Last item is %s\n", list->data, g_slist_last(list)->data); g_slist_free(list); }
/** * oh_add_rdr * @table: Pointer to RPT table containig the RPT entry to which the RDR will belong. * @rid: Id of the RPT entry that will own the RDR to be added. * @rdr: RDR to be added to an RPT entry's RDR repository. * @data: Pointer to private data belonging to the RDR that is being added. * @owndata: boolean flag. true (%KEEP_RPT_DATA) to tell the interface *not* * to free the data when the rdr is removed. false (%FREE_RPT_DATA) to tell * the interface to free the data when the rdr is removed. * * Add an RDR to a RPT entry's RDR repository. * If an RDR is found with the same record id as the one being added, the RDR being * added will overlay the existing one. Also, a unique record id will be assigned * to it based on the RDR type and its type's numeric id. * All rdr interface funtions, except oh_add_rdr() will act in the context of * the first RPT entry in the table, if @rid is %SAHPI_FIRST_ENTRY. * * Returns: SA_OK on success Or minus SA_OK on error. Will return * SA_ERR_HPI_INVALID_PARAMS if instrument id is invalid. An invalid * intrument id for a sensor is in the range of 0x100-0x1FF. An aggregate type * of sensor can have its instrument id in the range of 0x100-0x10F, but * the resource must have the aggregate sensor capabilitiy bit set. **/ SaErrorT oh_add_rdr(RPTable *table, SaHpiResourceIdT rid, SaHpiRdrT *rdr, void *data, int owndata) { RPTEntry *rptentry; RDRecord *rdrecord; SaHpiInstrumentIdT type_num; if (!rdr) { dbg("Failed to add. RDR is NULL."); return SA_ERR_HPI_INVALID_PARAMS; } rptentry = get_rptentry_by_rid(table, rid); if (!rptentry){ dbg("Failed to add RDR. Parent RPT entry was not found in table."); return SA_ERR_HPI_NOT_PRESENT; } if (check_instrument_id(&(rptentry->rpt_entry), rdr)) { dbg("Invalid instrument id found in RDR."); return SA_ERR_HPI_INVALID_PARAMS; } type_num = get_rdr_type_num(rdr); /* Form correct RecordId. */ rdr->RecordId = oh_get_rdr_uid(rdr->RdrType, type_num); /* Check if record exists */ rdrecord = get_rdrecord_by_id(rptentry, rdr->RecordId); /* If not, create new rdr */ if (!rdrecord) { rdrecord = (RDRecord *)g_malloc0(sizeof(RDRecord)); if (!rdrecord) { dbg("Not enough memory to add RDR."); return SA_ERR_HPI_OUT_OF_MEMORY; } /* Put new rdrecord in rdr repository */ rptentry->rdrlist = g_slist_append(rptentry->rdrlist, (gpointer)rdrecord); /* Create rdr hash table if first rdr here */ if (!rptentry->rdrtable) rptentry->rdrtable = g_hash_table_new(g_int_hash, g_int_equal); rdrecord->rdr.RecordId = rdr->RecordId; g_hash_table_insert(rptentry->rdrtable, &(rdrecord->rdr.RecordId), g_slist_last(rptentry->rdrlist)); } /* Else, modify existing rdrecord */ if (rdrecord->data && rdrecord->data != data && !rdrecord->owndata) g_free(rdrecord->data); rdrecord->data = data; rdrecord->owndata = owndata; rdrecord->rdr = *rdr; return SA_OK; }
static void primary_by_uuid_cb(guint8 status, const guint8 *ipdu, guint16 iplen, gpointer user_data) { struct discover_primary *dp = user_data; GSList *ranges, *last; struct att_range *range; uint8_t *buf; guint16 oplen; int err = 0; size_t buflen; if (status) { err = status == ATT_ECODE_ATTR_NOT_FOUND ? 0 : status; goto done; } ranges = dec_find_by_type_resp(ipdu, iplen); if (ranges == NULL) goto done; dp->primaries = g_slist_concat(dp->primaries, ranges); last = g_slist_last(ranges); range = last->data; if (range->end == 0xffff) goto done; /* * If last handle is lower from previous start handle then it is smth * wrong. Let's stop search, otherwise we might enter infinite loop. */ if (range->end < dp->start) { err = ATT_ECODE_UNLIKELY; goto done; } dp->start = range->end + 1; buf = g_attrib_get_buffer(dp->attrib, &buflen); oplen = encode_discover_primary(dp->start, 0xffff, &dp->uuid, buf, buflen); if (oplen == 0) goto done; g_attrib_send(dp->attrib, dp->id, buf, oplen, primary_by_uuid_cb, discover_primary_ref(dp), discover_primary_unref); return; done: dp->cb(err, dp->primaries, dp->user_data); }
int main(int argc, char** argv) { GSList* list = NULL; list = g_slist_append(list, "first"); list = g_slist_append(list, "second"); list = g_slist_append(list, "third"); printf("The last item is '%s'\n", g_slist_last(list)->data); printf("The item at index '1' is '%s'\n", g_slist_nth(list, 1)->data); printf("Now the item at index '1' the easy way: '%s'\n", g_slist_nth_data(list, 1)); printf("And the 'next' item after first item is '%s'\n", g_slist_next(list)->data); g_slist_free(list); return 0; }
static void promote_focus(widget_data_t *data) { designer_node_t *node; if (!data->design->nodes) return; node = g_slist_last(data->design->nodes)->data; if (node) set_root_focus (data, node); }
void g_slist_free (GSList *list) { GSList *last; if (list) { last = g_slist_last (list); last->next = current_allocator->free_list; current_allocator->free_list = list; } }
/** * g_slist_concat: * @list1: a #GSList * @list2: the #GSList to add to the end of the first #GSList * * Adds the second #GSList onto the end of the first #GSList. * Note that the elements of the second #GSList are not copied. * They are used directly. * * Returns: the start of the new #GSList */ GSList * g_slist_concat (GSList *list1, GSList *list2) { if (list2) { if (list1) g_slist_last (list1)->next = list2; else list1 = list2; } return list1; }