malloc.c 中的 "bk" 成员是什么缩写?
What abbr is "bk" member within malloc.c?
我的问题是关于 glibc 的。
bk
成员的名字是 malloc_chunk
的缩写?
struct malloc_chunk {
INTERNAL_SIZE_T mchunk_prev_size; /* Size of previous chunk (if free). */
INTERNAL_SIZE_T mchunk_size; /* Size in bytes, including overhead. */
struct malloc_chunk* fd; /* double links -- used only if free. */
struct malloc_chunk* bk;
/* Only used for large blocks: pointer to next larger size. */
struct malloc_chunk* fd_nextsize; /* double links -- used only if free. */
struct malloc_chunk* bk_nextsize;
};
参考:
https://code.woboq.org/userspace/glibc/malloc/malloc.c.html#malloc_chunk
fd
和bk
成员是双向link链表中的前向和后向指针。
换句话说,fd
是next
指针,bk
是previous
指针,如下三元表所示:
forward links -->
_(fd)_ _(fd)_
/ \ / \ _(fd)-> NULL
/ V / V /
head ---> item1 item2 item3
/ ^ / ^ /
NULL <-(bk)_/ \_(bk)_/ \_(bk)_/
<-- backward links
请注意,此特定示例有头和尾,结束元素指向 NULL。对于由 glibc
维护的循环列表,这可能 不是 的情况(因为它是一个 循环 列表),它只是用来显示一个实现方法。
事实上,您在问题中提供的 link 毫不含糊地说明了这一点,从结构定义之外的五十多行开始(略有释义):
Free chunks are stored in circular
doubly-linked lists, and look
like this:
+------------------------------------------+
| Size of previous chunk, if unallocated | <- mchunk_prev_size
+------------------------------------------+
| Size of chunk, in bytes (and some flags) | <- mchunk_size
+------------------------------------------+
| Forward pointer to next chunk in list | <- fd
+------------------------------------------+
| Back pointer to previous chunk in list | <- bk
+------------------------------------------+
: <other stuff> :
我的问题是关于 glibc 的。
bk
成员的名字是 malloc_chunk
的缩写?
struct malloc_chunk {
INTERNAL_SIZE_T mchunk_prev_size; /* Size of previous chunk (if free). */
INTERNAL_SIZE_T mchunk_size; /* Size in bytes, including overhead. */
struct malloc_chunk* fd; /* double links -- used only if free. */
struct malloc_chunk* bk;
/* Only used for large blocks: pointer to next larger size. */
struct malloc_chunk* fd_nextsize; /* double links -- used only if free. */
struct malloc_chunk* bk_nextsize;
};
参考: https://code.woboq.org/userspace/glibc/malloc/malloc.c.html#malloc_chunk
fd
和bk
成员是双向link链表中的前向和后向指针。
换句话说,fd
是next
指针,bk
是previous
指针,如下三元表所示:
forward links -->
_(fd)_ _(fd)_
/ \ / \ _(fd)-> NULL
/ V / V /
head ---> item1 item2 item3
/ ^ / ^ /
NULL <-(bk)_/ \_(bk)_/ \_(bk)_/
<-- backward links
请注意,此特定示例有头和尾,结束元素指向 NULL。对于由 glibc
维护的循环列表,这可能 不是 的情况(因为它是一个 循环 列表),它只是用来显示一个实现方法。
事实上,您在问题中提供的 link 毫不含糊地说明了这一点,从结构定义之外的五十多行开始(略有释义):
Free chunks are stored in circular
doubly-linked lists, and look
like this:
+------------------------------------------+
| Size of previous chunk, if unallocated | <- mchunk_prev_size
+------------------------------------------+
| Size of chunk, in bytes (and some flags) | <- mchunk_size
+------------------------------------------+
| Forward pointer to next chunk in list | <- fd
+------------------------------------------+
| Back pointer to previous chunk in list | <- bk
+------------------------------------------+
: <other stuff> :