[Spread-users] memory.c confusion [patch]
Theo Schlossnagle
jesus at omniti.com
Thu Sep 20 15:57:22 EDT 2001
The cvs copy of memory.c is a little confusing.
there is a #define that is invalid:
#define MEM_SIZE = sizeof(mem_header);
And then it isn't used (of course).
Also, the mem_header_ptr define is convoluted as they are all the same.
This patch makes it much cleaner and more obvious.
--
Theo Schlossnagle
1024D/82844984/95FD 30F1 489E 4613 F22E 491A 7E88 364C 8284 4984
2047R/33131B65/71 F7 95 64 49 76 5D BA 3D 90 B9 9F BE 27 24 E7
RCS file: /storage/cvsroot/spread/daemon/memory.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 memory.c
--- memory.c 21 Aug 2001 14:28:21 -0000 1.1.1.1
+++ memory.c 20 Sep 2001 19:54:36 -0000
@@ -80,7 +80,7 @@
int32u obj_type;
size_t block_len;
} mem_header;
-#define MEM_SIZE = sizeof(mem_header);
+#define MEM_SIZE sizeof(mem_header)
/* NOTE: Only num_obj_inpool is updated when debugging is turned off
* (i.e. define NDEBUG) it is NECESSARY to track buffer pool size
@@ -195,23 +195,11 @@
* by casting to (char *) we avoid the requirement that it be called
with void *.
*/
-/* OBSOLETE COMMENT! Size might not be 8.
- *
- * MUST BE CALLED WITH A VOID * pointer. OTHERWISE NASTY MEMORY
CORRUPTION OCCURS!!!
- * The value 8 is used here because obj is a void * so it is assumed to
point to an
- * array of chars (don't ask me why but it makes some sense)
- * thus we subtract 8 chars (8 * 1 byte chars = 8 bytes)
- * which is the size of the header
+/* MUST BE CALLED WITH A VOID * pointer. OTHERWISE NASTY MEMORY
CORRUPTION OCCURS!!!
+ * The value MEM_SIZE is defined above to be the size of the header.
+ * Cast to char * and subtract MEM_SIZE bytes as that is what sizeof
counts.
*/
-#ifdef ARCH_PC_WIN95
-# define mem_header_ptr(obj) ( (mem_header *) (((char
*)obj) - sizeof(mem_header) ) )
-#else
-#ifdef ARCH_SGI_IRIX
-# define mem_header_ptr(obj) ( (mem_header *) (((char
*)obj) - sizeof(mem_header) ) )
-#else
-# define mem_header_ptr(obj) ( (mem_header *) (((char
*)obj) - sizeof(mem_header) ) )
-#endif /* ARCH_SGI_IRIX */
-#endif /* ARCH_PC_WIN95 */
+#define mem_header_ptr(obj) ( (mem_header *) (((char *)obj) -
MEM_SIZE ) )
void Mem_init_status()
{
More information about the Spread-users
mailing list