La fonction g_array_insert_val(buckets, index, currentBucket); renvoie le pointeur de départ de ton tableau. A chaque fois que tu insères un nouvel élément, le pointeur de départ change. C'est le même principe avec les GList.
La documentation dit :
Inserts len elements into a GArray at the given index.
array : a GArray.
index_ : the index to place the elements at.
data : a pointer to the elements to insert.
len : the number of elements to insert.
Returns : the GArray.
En plus, il n'y a pas d'instruction return dans ta fonction ?
Donc en résumant :
Ca devrait te permettre de récupérer le pointeur de départ de ton tableau.
PS: je me permets de faire un peu de pub. Il existe un site ainsi qu'un forum sur l'utilisation des librairies GTK ( dont la Glib fait partie ) :
site : http://www.gtk-fr.org(...)
forum : http://forums.apinc.org(...)
[^] # Re: ah en fait
Posté par gerald dumas . En réponse au message glib: problem avec GArray. Évalué à 2.
La documentation dit :
GArray* g_array_insert_vals (GArray *array,
guint index_,
gconstpointer data,
guint len);
Inserts len elements into a GArray at the given index.
array : a GArray.
index_ : the index to place the elements at.
data : a pointer to the elements to insert.
len : the number of elements to insert.
Returns : the GArray.
En plus, il n'y a pas d'instruction return dans ta fonction ?
Donc en résumant :
GArray *bucket_insert(GArray* buckets, GaloisNode* node, guint index)
{
GList* currentBucket = g_array_index (buckets, GList*, index);
currentBucket = g_list_append(currentBucket, node);
buckets=g_array_insert_val(buckets, index, currentBucket);
return buckets;
}
Ca devrait te permettre de récupérer le pointeur de départ de ton tableau.
PS: je me permets de faire un peu de pub. Il existe un site ainsi qu'un forum sur l'utilisation des librairies GTK ( dont la Glib fait partie ) :
site : http://www.gtk-fr.org(...)
forum : http://forums.apinc.org(...)