03-26-2008 06:06 PM
03-27-2008 12:46 AM
03-27-2008 02:40 AM
Alternatively, you could consider replacing your FindTest function with a single ListFindItem () function inside your TestParameter function. ListFindItem requires a compare function which in your case could be something like this:
int compareFunc (void *element1, void *element2)
/*
Return values:
If element1 is compar returns
--------------------------------------------------------------
less than element2 less than zero
equal to element2 zero
greater than element2 greater than zero
*/
{
int ncar;
TestNode *e1, *e2;
e1 = (TestNode *)element1;
e2 = (TestNode *)element2;
//return strcmp (e1->cod, e2->cod);
ncar = Min (strlen(e1->key), strlen (e2->key));
return strncmp (e1->key, e2->key, ncar);
}
This function returns the position of found element inside the list, so you could use ListReplaceItem instead of appending a new item to the end of the list.
03-27-2008 11:24 AM
03-27-2008 05:21 PM - edited 03-27-2008 05:28 PM
Sorry, no; it does not follow.
The memory for the variables "temp", "count" and "x" is allocated on the heap, and becomes available to other threads in your process (and therefore liable to be trashed) immediately FindTest() returns.
Instead of:
result = &temp;
you could do this:
*result = temp;
which will copy the contents of "temp" to the variable "result" in the AddParameter() function.
Colin.
[Avogadro?]