Bruno Jesus 00cpxxx@gmail.com writes:
@@ -5546,24 +5546,70 @@ INT WINAPI WSAUnhookBlockingHook(void)
- pointers (via a template of some kind).
*/
-static int list_size(char** l, int item_size) +/***********************************************************************
list_size (INTERNAL)
- Calculate the size of data and number of items from a list based on
- a fixed item size or strings by using strlen. The source list must be
- NULL terminated.
- PARAMS
- l [I] Pointer to array of source items.
- item_size [I] Fixed item size or zero if it's a string list.
- size_sum [O] Pointer to where the sum of item bytes will be
stored. May be NULL if not required by the caller.
- item_count [O] Pointer to where the number of items bytes will be
stored. May be NULL if not required by the caller.
- NOTES
- When item_size is zero the byte sum will also count the NULL
- terminator for each string.
- */
+static void list_size(char** l, int item_size, int *size_sum, int *item_count) {
- int i,j = 0;
- if(l)
- { for(i=0;l[i];i++)
- j += (item_size) ? item_size : strlen(l[i]) + 1;
- j += (i + 1) * sizeof(char*); }
- return j;
- int s, c, *sum = (size_sum ? size_sum : &s), *count = (item_count ? item_count : &c);
- *sum = *count = 0;
- if(l)
- {
for(;l[*count];(*count)++)
*sum += (item_size) ? item_size : strlen(l[*count]) + 1;
- }
That's not a good helper function, with all the optional parameters and various behaviors. Also if you need a big documentation block like this for a 5-line function it's a sign that something is wrong.