On Wed, 5 Jan 2005, Dimitrie O. Paun wrote:
On Wed, Jan 05, 2005 at 01:58:45PM +0100, Peter Berg Larsen wrote:
+void strarray_set(strarray* arr, int index, const char* str) +{
- if (index >= arr->maximum)
- {
- arr->maximum = index+10;
- arr->base = xrealloc(arr->base, sizeof(*(arr->base)) * arr->maximum);
- memset(&(arr->base[arr->size]),0,sizeof(*(arr->base)) * (arr->maximum - arr->size));
- }
- arr->base[index] = str;
- if (arr->size <= index)
arr->size = index+1;
+}
Do we really need this strarray_set() function?
No, but it is convinient to have. I need the fullpaths to the .so libraries at certain point. Basicly I saw two ways of doing what:
1) Call [get|guess|try]_lib_path at the that point.
2) Save all previous result from get_lib_path. So now I need a way to link a file to the full path. The easiest way was to add a fullnames array, which had a 1-1 correspondence with the file array. However not every file has a fullname (fx. a file can also be a include directive), and the call get_lib_path is in a 60+ line foreach(@file)if/switch/else/switch part; so to keep it simple I need a set(index,element).
Even if you do, it should _not_ shorten the array.
Agreed. And the intension was that it shouldnt. I may be code blind, but do you see any way that it does shorten the array? maximum := the allocated array size, size := number of used entries in the array (0 ... size-1)
Peter