V2EX  ›  英汉词典

Realloc

释义 Definition

realloc 是 C 语言标准库中的函数名,表示“重新分配内存”:在保留原有数据(尽可能)的前提下,把一块已分配的内存块扩容或缩小到新的大小,并返回(可能变化的)新地址。它也常被口语化地用作动词,指“重新分配(资源/内存)”。(在非编程语境中更常见的是 reallocate。)

发音 Pronunciation (IPA)

/ˌriːˈælɒk/

例句 Examples

I used realloc to grow the array.
我用 realloc 把数组扩容了。

If realloc fails, it returns NULL, so you should store the result in a temporary pointer before replacing the original one.
如果 realloc 失败,它会返回 NULL,所以应先用临时指针接收结果,再替换原指针。

词源 Etymology

realloc 可看作 **re-**(再、重新)+ **alloc(ate)**(分配) 的缩写形式;在 C 标准库中与 malloc / calloc / free 并列,名称短、便于在代码中频繁使用。其核心含义是“对已分配内存做再次分配(调整大小)”。

相关词 Related Words

文学与作品 Literary Works

  • The C Programming Language(Kernighan & Ritchie):在动态内存管理相关章节/示例中讨论与使用 mallocrealloc 等函数。
  • The Linux Programming Interface(Michael Kerrisk):在内存分配与系统编程实践中多处提及 realloc 的用法与注意事项。
  • C Programming: A Modern Approach(K. N. King):在指针与动态数组等内容中出现 realloc 的示例与练习。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2081 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 13:19 · PVG 21:19 · LAX 05:19 · JFK 08:19
♥ Do have faith in what you're doing.