我应该免费的指针由getpwuid()在Linux中回来了? [英] should I free pointer returned by getpwuid() in Linux?

查看:227
本文介绍了我应该免费的指针由getpwuid()在Linux中回来了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我调用getpwuid(UID),​​我有一个指针引用。我应该释放,当我不使用它了?读手册页,它说,它提到一些静态区域,可能的后续调用相同的功能覆盖,所以我敢肯定,肯定我是否应该接触到存储区。

After I call getpwuid(uid), I have a reference to a pointer. Should I free that when I don't use it anymore? Reading the man pages, it says that it makes reference to some static area, that may be overwritten by subsequent calls to the same functions, so I'm sure sure if I should touch that memory area.

感谢。

推荐答案

没有。不需要释放的结果。只能调用free(3)使用malloc(3),释放calloc在堆中分配指针(3)或realloc(3)。

No. You do not need to free the result. You can only call free(3) on pointers allocated on the heap with malloc(3), calloc(3) or realloc(3).

静态数据是一个程序的数据或BSS段的一部分,将持续到进程退出(或者被覆盖的exec(2))。

Static data is part of a program's data or bss segments and will persist until the process exits (or is overwritten by exec(2)).

这篇关于我应该免费的指针由getpwuid()在Linux中回来了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆