分类 C/C++ 下的文章

mmap() will be called by malloc()?

In the man page of malloc, there(NOTES section) is a paragraph as follows:

Normally, malloc() allocates memory from the heap, and adjusts the size of the heap as required, using sbrk(2). When allocating blocks of memory larger than MMAP_THRESHOLD bytes, the glibc malloc() implementation allocates the memory as a private anonymous mapping using mmap(2). MMAP_THRESHOLD is 128 kB by default, but is adjustable using mallopt(3). Prior to Linux 4.7 allocations performed using mmap(2) were unaffected by the RLIMIT_DATA resource limit; since Linux 4.7, this limit is also enforced for allocations performed using mmap(2).

- 阅读剩余部分 -

Keyword restrict in C99

While reading Advanced Programming in the UNIX Environment, I noticed this:

#include <stdio.h>
FILE* fmemopen(void *restrict buf, size_t size, const char *restrict type);

What is the keyword restrict for?

- 阅读剩余部分 -