Flash Gordon wrote:
CBFalconer wrote, On 26/12/07 21:11:
>riva wrote:
>>We merely pass the pointer to dynamically allocated variable to
free() function. How does it decide about the number of bytes to
be freed?
Raw black magic.
Nope. On mine the black magic has been grilled under a low heat.
Don't you find that that allows the basic greasy black material to
leak out, so that heavily realloced buffers tend to fail to free
abandoned buffers, resulting in memory leaks?
Code such as the following can be used to detect this sort of
'black leak':
size_t ct
char *p, *t;
for (p = NULL, ct = 0; ++ct;) {
if (t = realloc(p, ct)) p = t;
else break;
}
if (t == p) /* no realloc failure occured */
analyzemem(p); /* system dependant code */
}
else failanalyze(p); /* also system dependant */
--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee, Frohe Weihnachten
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from
http://www.teranews.com