Commit 6d17918e authored by Jules Sang's avatar Jules Sang
Browse files

repaired pointers arithmetic with unsigned longs

parent b9ee67e8
{
"files.associations": {
"python.h": "c"
"python.h": "c",
"mem.h": "c"
}
}
\ No newline at end of file
......@@ -19,9 +19,12 @@ void *mark_memarea_and_get_user_ptr(void *ptr, unsigned long size, MemKind k)
{
unsigned long magic_number = (knuth_mmix_one_round((unsigned long) ptr) & ~(0b11UL)) | k;
*((unsigned long*) ptr) = size;
*((unsigned long*) ptr+1) = magic_number;
*((unsigned long*) ptr + size/8 - 2)= magic_number;
*((unsigned long*) ptr + size/8 - 1) = size;
// *((unsigned long*) ptr+1) = magic_number;
*(unsigned long*) (((char*) ptr) + 8) = magic_number;
// *((unsigned long*) ptr + size/8 - 2)= magic_number;
*(unsigned long*) (((char*) ptr) + size - 16) = magic_number;
// *((unsigned long*) ptr + size/8 - 1) = size;
*(unsigned long*) (((char*) ptr) + size - 8) = size;
return ((char*) ptr) + 16;
}
......@@ -38,7 +41,8 @@ mark_check_and_get_alloc(void *ptr)
assert(magic_number == expected_magic_number);
// assertion of marquage coherence for magic_number & size
unsigned long size_at_end = *((unsigned long*) data_beginning + size/8 - 1);
// unsigned long size_at_end = *((unsigned long*) data_beginning + size/8 - 1);
unsigned long size_at_end = *(unsigned long*) (((char*) data_beginning + size - 8));
assert(size == size_at_end);
Alloc a = { data_beginning, k, size };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment