浏览代码

(MALLOC_SETUP): New macro.
(MALLOC_SET_SIZE): Take the base-address of the block, not the user-address.
(MALLOC_ADDR): Macro removed.

Miles Bader 23 年之前
父节点
当前提交
5a0af72d6d
共有 1 个文件被更改,包括 6 次插入5 次删除
  1. 6 5
      libc/stdlib/malloc/malloc.h

+ 6 - 5
libc/stdlib/malloc/malloc.h

@@ -61,15 +61,16 @@
 /* The amount of extra space used by the malloc header.  */
 #define MALLOC_HEADER_SIZE	MALLOC_ALIGNMENT
 
+/* Set up the malloc header, and return the user address of a malloc block. */
+#define MALLOC_SETUP(base, size)  \
+  (MALLOC_SET_SIZE (base, size), (void *)((char *)base + MALLOC_HEADER_SIZE))
+/* Set the size of a malloc allocation, given the base address.  */
+#define MALLOC_SET_SIZE(base, size)	(*(size_t *)(base) = (size))
+
 /* Return base-address of a malloc allocation, given the user address.  */
 #define MALLOC_BASE(addr)	((void *)((char *)addr - MALLOC_HEADER_SIZE))
 /* Return the size of a malloc allocation, given the user address.  */
 #define MALLOC_SIZE(addr)	(*(size_t *)MALLOC_BASE(addr))
-/* Sets the size of a malloc allocation, given the user address.  */
-#define MALLOC_SET_SIZE(addr, size)	(*(size_t *)MALLOC_BASE(addr) = (size))
-
-/* Return the user address of a malloc allocation, given the base address.  */
-#define MALLOC_ADDR(base)	((void *)((char *)base + MALLOC_HEADER_SIZE))
 
 
 /* Locking for multithreaded apps.  */