Hello Riccardo, > I wrote an "extensible array" code as part of a larger project, and > thought it could be of some interest to GNUlib. However, I'm not sure > it does not fall into the category of "stuff that would be better > packaged separately", so I'm inquiring here first, before wrapping it > up properly as a patch. > > The "XARRAY" macro creates an array of any given C type (plus some > optional headers), and defines functions to append/remove/insert > elements into the array. Documentation is in the attached C header file; > the test case shows a usage sample.
gnulib intends to be a home for reusable and useful code like this one. However, there is some overlap with two modules that already exist in gnulib: - 'xalloc' (main source files: xalloc.h, xmalloc.c), - 'list' and 'array-list' (main source files: gl_list.h, gl_array_list.c). 'xalloc' is lower level than your 'xarray' module; we use it when it's not a big burden to think about memory allocations explicitly. 'list' and 'array-list' are at a higher level than your 'xarray' module: they implement a more general "ordered list" interface. Code written with these module can be turned into linked list, hash table, or balanced binary tree with a change of just one line of code. On the other hand, these modules require a 'void *' as data type; your 'xarray' is more memory efficient when the data type is 'char' or 'double[2]'. Does gnulib need an 'xarray' module between 'xalloc' and 'list'/'array-list'? I'm a bit undecided. Opinions? Bruno
