aboutsummaryrefslogtreecommitdiffstats
path: root/epan/emem.c
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames-ws@darkjames.pl>2012-04-10 20:58:14 +0000
committerJakub Zawadzki <darkjames-ws@darkjames.pl>2012-04-10 20:58:14 +0000
commit4f3e8427f39ee9ae30a44c0197bed71e4f30c2b1 (patch)
treef7e706fc6db2393fee3f8af75330b136f4253519 /epan/emem.c
parent2d6301dd908a48d45895c5264209c53820da7e6b (diff)
Revert r42001
svn path=/trunk/; revision=42013
Diffstat (limited to 'epan/emem.c')
-rw-r--r--epan/emem.c40
1 files changed, 5 insertions, 35 deletions
diff --git a/epan/emem.c b/epan/emem.c
index 94baeca0e6..0e5478efcc 100644
--- a/epan/emem.c
+++ b/epan/emem.c
@@ -576,9 +576,6 @@ se_verify_pointer(const void *ptr)
return FALSE;
}
-#define SCRUB_ALLOC_VALUE 0xBADDCAFE
-#define SCRUB_FREED_VALUE 0xDEADBEEF
-
static void
emem_scrub_memory(char *buf, size_t size, gboolean alloc)
{
@@ -589,32 +586,9 @@ emem_scrub_memory(char *buf, size_t size, gboolean alloc)
return;
if (alloc) /* this memory is being allocated */
- scrubbed_value = SCRUB_ALLOC_VALUE;
+ scrubbed_value = 0xBADDCAFE;
else /* this memory is being freed */
- scrubbed_value = SCRUB_FREED_VALUE;
-
- /* check if memory is scrubbed */
- if (alloc) {
- for (offset = 0; offset + sizeof(guint) <= size; offset += sizeof(guint)) {
- if (*(guint*)(void*)(buf+offset) != SCRUB_FREED_VALUE)
- g_error("Memory corrupted (not scrubbed) %.8x", *(guint*)(void*)(buf+offset));
- }
- /* Initialize the last bytes, if any */
- if (offset < size) {
- if (*(guint8*)(buf+offset) != (SCRUB_FREED_VALUE & 0xff))
- g_error("Memory corrupted (not scrubbed) %.2x", *(guint8*)(buf+offset));
- offset++;
- if (offset < size) {
- if (*(guint8*)(buf+offset) != ((SCRUB_FREED_VALUE >> 8) & 0xff))
- g_error("Memory corrupted (not scrubbed) %.2x", *(guint8*)(buf+offset));
- offset++;
- if (offset < size) {
- if (*(guint8*)(buf+offset) != ((SCRUB_FREED_VALUE >> 16) & 0xff))
- g_error("Memory corrupted (not scrubbed) %.2x", *(guint8*)(buf+offset));
- }
- }
- }
- }
+ scrubbed_value = 0xDEADBEEF;
/* We shouldn't need to check the alignment of the starting address
* since this is malloc'd memory (or 'pagesize' bytes into malloc'd
@@ -631,15 +605,13 @@ emem_scrub_memory(char *buf, size_t size, gboolean alloc)
/* Initialize the last bytes, if any */
if (offset < size) {
- *(guint8*)(buf+offset) = scrubbed_value;
+ *(guint8*)(buf+offset) = scrubbed_value >> 24;
offset++;
if (offset < size) {
- scrubbed_value >>= 8;
- *(guint8*)(buf+offset) = scrubbed_value;
+ *(guint8*)(buf+offset) = (scrubbed_value >> 16) & 0xFF;
offset++;
if (offset < size) {
- scrubbed_value >>= 8;
- *(guint8*)(buf+offset) = scrubbed_value;
+ *(guint8*)(buf+offset) = (scrubbed_value >> 8) & 0xFF;
}
}
}
@@ -697,8 +669,6 @@ emem_create_chunk(size_t size)
npc->amount_free = npc->amount_free_init = (unsigned int) size;
npc->free_offset = npc->free_offset_init = 0;
-
- emem_scrub_memory(npc->buf, size, FALSE);
return npc;
}