+}
+
+#ifdef SMALLOC_REDZONE
+static void *postred_ptr(struct block_hdr *hdr)
+{
+ uintptr_t ptr;
+
+ ptr = (uintptr_t) hdr + hdr->size - sizeof(unsigned int);
+ ptr = (uintptr_t) PTR_ALIGN(ptr, int_mask);
+
+ return (void *) ptr;
+}
+
+static void fill_redzone(struct block_hdr *hdr)
+{
+ unsigned int *postred = postred_ptr(hdr);
+
+ hdr->prered = SMALLOC_PRE_RED;
+ *postred = SMALLOC_POST_RED;
+}
+
+static void sfree_check_redzone(struct block_hdr *hdr)
+{
+ unsigned int *postred = postred_ptr(hdr);
+
+ if (hdr->prered != SMALLOC_PRE_RED) {
+ log_err("smalloc pre redzone destroyed!\n"
+ " ptr=%p, prered=%x, expected %x\n",
+ hdr, hdr->prered, SMALLOC_PRE_RED);
+ assert(0);
+ }
+ if (*postred != SMALLOC_POST_RED) {
+ log_err("smalloc post redzone destroyed!\n"
+ " ptr=%p, postred=%x, expected %x\n",
+ hdr, *postred, SMALLOC_POST_RED);
+ assert(0);
+ }
+}
+#else
+static void fill_redzone(struct block_hdr *hdr)
+{
+}