+char *memname[] = INITKMEMNAMES;
+char *kmembase, *kmemlimit;
+char *memname[] = INITKMEMNAMES;
+long malloc_reentered;
+#define IN { if (malloc_reentered) panic("malloc reentered");\
+ else malloc_reentered = 1;}
+#define OUT (malloc_reentered = 0)
+
+#ifdef DIAGNOSTIC
+/*
+ * This structure serves two purposes.
+ * The first is to provide a set of masks to catch unaligned frees.
+ * The second is to provide known text to copy into free objects so
+ * that modifications after frees can be detected.
+ */
+#define WEIRD_ADDR 0xdeadbeef
+long addrmask[] = { WEIRD_ADDR,
+ 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
+ 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
+ 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
+ 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
+};
+
+/*
+ * Normally the first word of the structure is used to hold the list
+ * pointer for free objects. However, when running with diagnostics,
+ * we use the third and fourth fields, so as to catch modifications
+ * in the most commonly trashed first two words.
+ */
+struct freelist {
+ long spare0;
+ long spare1;
+ short type;
+ short spare2;
+ caddr_t next;
+};
+#else /* !DIAGNOSTIC */
+struct freelist {
+ caddr_t next;
+};
+#endif /* DIAGNOSTIC */