王乾发 2016-08-08 09:20 采纳率: 0%
浏览 1180

请教熟悉apr函数库的大神:函数apr_pstrndup的工作方式

因为开发FreeSWITCH,接触到Apache的函数库libapr。
对于其字符串函数的工作方式很不理解,请教一下。
这个函数的格式如下:
char* apr_pstrndup ( apr_pool_t * p, const char * s, apr_size_t n )

Duplicate at most n characters of a string into memory allocated out of a pool; the new string will be NUL-terminated

Parameters:
p The pool to allocate out of
s The string to duplicate
n The maximum number of characters to duplicate
Returns:
The new string
Remarks:
The amount of memory allocated from the pool is the length of the returned string including the NUL terminator

看上去很好理解,就是从内存池中分配一个新的空间,把现有内容复制过去。
但是问题来了:我没有看到清理这片内存的函数。也就是说,这片被分配的内容,要一直等到内存池被销毁的时候,才会被清理吗?这样也太不科学了。
有哪位大神可以解答一下我的疑问?

  • 写回答

2条回答 默认 最新

  • devmiao 2016-08-08 09:37
    关注
    评论

报告相同问题?

悬赏问题

  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败