Re: question of uListSearch
[email protected] Sat, 02 May 2009 00:34:31 +0800
| Newsgroups | gmane.text.clearsilver.general |
|---|---|
| Message-ID | <[email protected]> |
> On 04/30/09 [email protected] uttered the following other thing: > > > > Hi, my process core dump when I using uListSearch, i found that the > > 2st parameter for bsearch SHOULD BE ul->items[0], or *ul->items in > > line 225 of ulist.c > > > > return bsearch(key, ul->items, ul->num, sizeof(void *), compareFunc); > > No, its correct as is. The usage of uList and the compareFunc's isn't > very obvious. In fact, its possible that the "bug" is that the above > should be: > > return bsearch(&key, ul->items, ul->num, sizeof(void *), compareFunc); > > With the current code, you need to pass in the pointer to what you want, > which isn't very obvious. See the attached expanded ulist_test.c code > for an example usage. > > I feel like I should fix the code, but that would break anyone currently > using it, so no dice with that. > en, ulist_test.c show the correct way to use uListSearch, after modify my prog accrodding stringCompare(), it work correct, thanks! > > BTW, string_array_split() should judge doese strduped string is empty, > > > > e.g. string_array_split(&list, "/home/bigmaliang", "/") will strdup a empty > > string in line 235 of neo_str.c > > > > n = strdup(f); > > You're asking that it doesn't include the empty string? The above > behavior does match python split, for instance: > > # python -c 'print "/home/bigmaliang".split("/")' > ['', 'home', 'bigmaliang'] yes, I don't want include the empty string. caller must check dose the value in the list is empty, also the python do so :) > > Brandon > -- > "The meek shall inherit the earth; now let's check out who gets heaven." > -- J. Neil Shulman > http://www.fiction.net/blong/