/* This code is only for x86_64 gcc linux. It is NOT threadsafe. */
+void* slice_alloc (size_t length) {
+ static intptr_t *nextslice = NULL + 1;
+ static intptr_t *lastslice = NULL;
+
+ int num = length / sizeof(intptr_t) + 1;
+
+ if (lastslice < nextslice + num) {
+ nextslice = (intptr_t *)malloc(1024*sizeof(intptr_t));
+ lastslice = nextslice + 1023;
+ }
+
+ void* ret = (void*) nextslice;
+ nextslice += num;
+ return ret;
+}
+
/* w00t, I am a three-star-programmer! */
void ***dereferencedPointer;
void ***lastDereferencedPointer;
lockedPointer++;
dereferencedPointer++;
- /* we should use a slice allocator here */
- tree_entry *en = (tree_entry*) malloc (sizeof(tree_entry));
+ tree_entry *en = (tree_entry*) slice_alloc (sizeof(tree_entry));
en->function = calculate;
en->argument = opt;
en->dereferencedPointer = ret;
}
void *calculateLazy24 (void* bla) {
- int* ret = (int*) malloc(sizeof(int));
+ int* ret = (int*) slice_alloc (sizeof(int));
*ret = 42;
return (void*) ret;
}