这是Kernighan和Ritchie关于C的书的摘录.它显示了如何实现一个版本malloc.虽然评论很好,但我很难理解它.有人可以解释一下吗?
typedef long Align; /* for alignment to long boundary */
union header { /* block header */
struct {
union header *ptr; /* next block if on free list */
unsigned size; /* size of this block */
} s;
Align x; /* force alignment of blocks */
};
typedef union header Header;
static Header base; /* empty list to get started */
static Header *freep = NULL; /* start of free list */
/* …Run Code Online (Sandbox Code Playgroud)