[patch] tsearch.3: dispose properly of allocated resources in example code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As there are many users who base their own code on these examples, we should avoid leaking memory when using functions of tsearch() family.In the provided example, tsearch() leaks memory whenever it tries to insert a number which was already inserted before.
Please CC me, as I´m not subscribed.
Applies to man-pages-3.09.
--- man3/tsearch.3	2008-09-10 10:16:13.000000000 -0300+++ man3/tsearch.3.goddard	2008-09-21 03:12:43.000000000 -0300@@ -246,8 +246,11 @@         val = tsearch((void *) ptr, &root, compare);         if (val == NULL)             exit(EXIT_FAILURE);+        else if ((*(int **) val) != ptr)+            free(ptr);     }     twalk(root, action);+    tdestroy(root, free);     exit(EXIT_SUCCESS); } .fiÿôèº{.nÇ+?·?®?­?+%?Ëÿ±éݶ¥?wÿº{.nÇ+?·¥?{±þf§þ)í?æèw*jg¬±¨¶????Ý¢jÿ¾«þG«?éÿ¢¸¢·¦j:+v?¨?wèjØm¶?ÿþø¯ù®w¥þ?àþf£¢·h??â?úÿ?Ù¥


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux