Blame SOURCES/ElectricFence-2.2.2-malloc_usable_size.patch

94c734
diff -up ElectricFence-2.2.2/efence.c\~ ElectricFence-2.2.2/efence.c
94c734
--- ElectricFence-2.2.2/efence.c~	2012-03-12 22:48:22.634989256 +0100
94c734
+++ ElectricFence-2.2.2/efence.c	2012-03-12 23:05:00.545522379 +0100
94c734
@@ -865,6 +865,41 @@ free(void * address)
94c734
 	release();
94c734
 }
94c734
 
94c734
+extern C_LINKAGE size_t
94c734
+malloc_usable_size(void * address)
94c734
+{
94c734
+	Slot *	slot;
94c734
+
94c734
+	lock();
94c734
+
94c734
+	if ( !noAllocationListProtection )
94c734
+		Page_AllowAccess(allocationList, allocationListSize);
94c734
+
94c734
+	slot = slotForUserAddress(address);
94c734
+
94c734
+	if ( !slot )
94c734
+		EF_Abort("free(%a): address not from malloc().", address);
94c734
+
94c734
+	if ( slot->mode != ALLOCATED ) {
94c734
+		if ( internalUse && slot->mode == INTERNAL_USE )
94c734
+			/* Do nothing. */;
94c734
+		else {
94c734
+			EF_Abort(
94c734
+			 "free(%a): malloc_usable_size on freed block."
94c734
+			,address);
94c734
+		}
94c734
+	}
94c734
+
94c734
+	size_t ret = slot->userSize;
94c734
+
94c734
+	if ( !noAllocationListProtection )
94c734
+		Page_DenyAccess(allocationList, allocationListSize);
94c734
+
94c734
+	release();
94c734
+
94c734
+	return ret;
94c734
+}
94c734
+
94c734
 extern C_LINKAGE void *
94c734
 realloc(void * oldBuffer, size_t newSize)
94c734
 {
94c734
94c734
Diff finished.  Mon Mar 12 23:06:53 2012