如何查找释放的字节数 [英] how to find number of bytes freed
问题描述
有什么方法可以找出在C中的特定
free()调用中释放的字节数
< blockquote> sh******@gmail.com 说:
是否有任何方法可以找出在C
中特定
free()调用中释放的字节数
你分配这个存储空间,就知道你分配了多少存储空间。
别忘了。
然后,当你来免费它,你知道吗?
-
Richard Heathfield< http://www.cpax.org.uk>
电子邮件:-http:// www。 + rjh @
谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>
Usenet是一个奇怪的放置" - dmr 1999年7月29日
8月8日,9:58 * am,sh.vi ... @ gmail.com写道:
是否有任何方法可以找出在C
中的特定
free()调用中释放的字节数
唯一可移植的方法是在最初分配内存时存储该信息(如果您随后成功地使用该指针调用realloc,则更新它)。如果你想要不可移植的方式,你可以尝试在平台特定组中询问。即使在那里,它可能取决于您使用的具体标准库实现,
并且可能无法以任何方式提供。
-David
8月8日晚上7点10分,Richard Heathfield< r ... @ see.sig.invalidwrote:
< blockquote class =post_quotes>
sh.vi ... @ gmail.com说:
有没有办法找出释放的字节数在特定的
免费()调用C
分配此存储时,您知道分配了多少存储空间。
别忘了。
然后,当你来释放它时,你知道,对吧?
-
Richard Heathfield< http://www.cpax.org.uk>
电子邮件:-http:// www。 + rjh @
谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>
Usenet是一个奇怪的放置" - dmr 1999年7月29日
是的,但是我必须在分配时存储这些信息(分配的字节数为b
) 。所以还有一个指针
和它链接的字节数之间的链接...基本上我没有;我想要
写我自己的内存分配器。
is there any way to find out number of bytes freed on a particular
free() call in C
sh******@gmail.com said:
is there any way to find out number of bytes freed on a particular
free() call in CWhen you allocate this storage, you know how much storage you allocated.
Don''t Forget.
Then, when you come to free it, you know, right?
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
On Aug 8, 9:58*am, sh.vi...@gmail.com wrote:is there any way to find out number of bytes freed on a particular
free() call in CThe only portable way is to store that information when you initially
allocate the memory (and update it if you subsequently successfully
call realloc using that pointer). If you want non-portable ways, you
could try asking in a platform specific group. Even there, it may
depend on what specific standard library implementation you are using,
and may simply not be available by any means.
-David
On Aug 8, 7:10 pm, Richard Heathfield <r...@see.sig.invalidwrote:sh.vi...@gmail.com said:
is there any way to find out number of bytes freed on a particular
free() call in C
When you allocate this storage, you know how much storage you allocated.
Don''t Forget.
Then, when you come to free it, you know, right?
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999yea but then i will have to store this information (number of bytes
allocated) at the time of allocation. so also a link between a pointer
and number of bytes it is linked with ...esentially i don;t want to
write my own memory allocator.
这篇关于如何查找释放的字节数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!