Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2005, 10:31
WhoCares's Avatar
WhoCares WhoCares is offline
who cares
 
Join Date: Jan 2002
Location: Here
Posts: 468
Rept. Given: 11
Rept. Rcvd 32 Times in 25 Posts
Thanks Given: 69
Thanks Rcvd at 247 Times in 94 Posts
WhoCares Reputation: 32
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.
Reply With Quote
  #2  
Old 01-07-2005, 16:43
SiNTAX SiNTAX is offline
Friend
 
Join Date: Sep 2002
Posts: 22
Rept. Given: 2
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 0
Thanks Rcvd at 0 Times in 0 Posts
SiNTAX Reputation: 0
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)
Reply With Quote
  #3  
Old 01-07-2005, 18:41
WhoCares's Avatar
WhoCares WhoCares is offline
who cares
 
Join Date: Jan 2002
Location: Here
Posts: 468
Rept. Given: 11
Rept. Rcvd 32 Times in 25 Posts
Thanks Given: 69
Thanks Rcvd at 247 Times in 94 Posts
WhoCares Reputation: 32
Thanks. That's the quick solution.
__________________
AKA Solomon/blowfish.
Reply With Quote
  #4  
Old 01-07-2005, 23:53
SiNTAX SiNTAX is offline
Friend
 
Join Date: Sep 2002
Posts: 22
Rept. Given: 2
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 0
Thanks Rcvd at 0 Times in 0 Posts
SiNTAX Reputation: 0
Well.. if rather fancy a challenge, you could always do this:
Code:
objdump -d /lib/tls/libc.so.6 |sed -n -e '/<tdestroy>:/,/^$/ p'
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


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


All times are GMT +8. The time now is 22:40.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )