GArrays memory, access time and cache friendlyness

Are GArrays stored in memory contiguously? If so are they cache friendly?

Acessing a GArray element by index with GArray_index() is O(1)?

Yes

The docs for GArray

struct GArray {
  gchar *data;
  guint len;
};

The source for g_array_index

#define g_array_index(a,t,i)      (((t*) (void *) (a)->data) [(i)])

GArray is really just a refcounted box around a lump of memory with some sugar for working with it

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.