提交 ef8d45d6 编写于 作者: R Rich Felker

rework malloc_usable_size to use malloc_impl.h

上级 055dfbb7
#include <malloc.h>
#include "malloc_impl.h"
void *(*const __realloc_dep)(void *, size_t) = realloc;
struct chunk {
size_t psize, csize;
struct chunk *next, *prev;
};
#define OVERHEAD (2*sizeof(size_t))
#define CHUNK_SIZE(c) ((c)->csize & -2)
#define MEM_TO_CHUNK(p) (struct chunk *)((char *)(p) - OVERHEAD)
size_t malloc_usable_size(void *p)
{
return p ? CHUNK_SIZE(MEM_TO_CHUNK(p)) - OVERHEAD : 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册