![]() |
|
#1
|
||||
|
||||
|
porting GNU tdestroy() function to SPARC Solaris
The GNU tdestroy() function only exists in Linux. Currently I have to port it to SPARC Solaris 9. It seems that tdestroy() can't be implemented with tsearch/tfind/tdelete/twalk combinations. I will be shocked if this is true because it will be ridiculous for the API function designers if there is no way to free all the resources of a tree in Solaris OS. Do I have to re-write the whole bunch of tree manipulation functions from scratch?
http://www.planetpenguin.de/manpage-3-tdestroy.3.html
__________________
AKA Solomon/blowfish. Last edited by WhoCares; 01-07-2005 at 10:37. |
|
#2
|
|||
|
|||
|
I don't know anything about slowaris, but you could look in the glibc sources (but don't forget, this is GPL code)
ie.. glibc-2.3.2/misc/tsearch.c : Code:
/* The standardized functions miss an important functionality: the
tree cannot be removed easily. We provide a function to do this. */
static void
internal_function
tdestroy_recurse (node root, __free_fn_t freefct)
{
if (root->left != NULL)
tdestroy_recurse (root->left, freefct);
if (root->right != NULL)
tdestroy_recurse (root->right, freefct);
(*freefct) ((void *) root->key);
/* Free the node itself. */
free (root);
}
void
__tdestroy (void *vroot, __free_fn_t freefct)
{
node root = (node) vroot;
CHECK_TREE (root);
if (root != NULL)
tdestroy_recurse (root, freefct);
}
weak_alias (__tdestroy, tdestroy)
|
|
#3
|
||||
|
||||
|
Thanks. That's the quick solution.
__________________
AKA Solomon/blowfish. |
|
#4
|
|||
|
|||
|
Well.. if rather fancy a challenge, you could always do this:
Code:
objdump -d /lib/tls/libc.so.6 |sed -n -e '/<tdestroy>:/,/^$/ p'
|
![]() |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ollydbg v1 to v2 porting question | sendersu | General Discussion | 0 | 09-02-2014 13:29 |
| Is there a debugger like softice in solaris sparc? | TCM909 | General Discussion | 0 | 05-06-2005 02:07 |
| Need a guideline in porting cpp to c | arkanoid | General Discussion | 13 | 01-18-2005 22:26 |