c - Function to get the Size of allocated Memory from pointer only
问题描述
How is it possible to get the size of memory allocated knowing only the pointer name returned by malloc function ? I suppose it is possible because free function as only this pointer as parameter but I do not know how to do that.
size_t myfoo (void *ptr) {
/* some instruction to get the size : This is the question*/ }
main () {
int * ptr;
ptr=malloc(100);
printf("%ud \n",myfoo(ptr)); }
解决方案
推荐阅读
- html - 滚动条未显示在我的第一个网站文件中
- java - Google NTP 服务器有时不响应
- javascript - 全局变量在 node.js 服务器上不起作用
- angular - 反应形式给出错误属性“电子邮件”在类型“AppComponent”上不存在
- c# - 想列出经理团队的评价
- javascript - ASP.NET MVC Home\Index 页面中未使用 mmenu 插件
- angular - Angular:如果一个延迟加载的模块从另一个延迟加载的模块调用服务会发生什么?
- python - Selenium 不保持缓存有效
- python - 我正在观看 Mike Dane 关于 Guessing Game 的 Python 教程,我对代码感到困惑
- sql - Presto SQL 使用 ST_intersects 左连接,ST_crosses 产生意外结果