开发者社区> 问答> 正文

在gethostbyname_r后不管塞给它的hostent,是否会有内存泄漏问题?

在gethostbyname_r后不管塞给它的hostent,是否会有内存泄漏问题?

展开
收起
我的中国 2017-11-30 18:07:53 2575 0
2 条回答
写回答
取消 提交回答
  • 这hostent难道不是你调用者自己分配的么?

    2019-07-17 21:46:40
    赞同 展开评论 打赏
  • R&S网络资深工程师 ,阿里云论坛官方版主,阿里云云计算ACP,春考教学网站长,IT技术晋级之路专辑作者

    You should print out the values of the pointers in that struct to find out the answer to your question. You'll discover that they all point to data inside the buffer you allocated.

    So a single free is all you need to free up all the memory.

    But this also means that you must not free that allocation until you've finished using or copying whatever data you're interested in.

    2019-07-17 21:46:40
    赞同 展开评论 打赏
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
内存取证与IaaS云平台恶意行 为的安全监控 立即下载
云服务器ECS内存增强型实例re6全新发布 立即下载
低代码开发师(初级)实战教程 立即下载