projects
/
lazyeval.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
402fadd
)
added a slice allocator
author
christoph
<christoph@thinkpad.lan>
Wed, 28 Dec 2011 19:16:15 +0000
(20:16 +0100)
committer
christoph
<christoph@thinkpad.lan>
Wed, 28 Dec 2011 19:16:15 +0000
(20:16 +0100)
withMulklib.c
patch
|
blob
|
history
diff --git
a/withMulklib.c
b/withMulklib.c
index
cf4bf4f
..
f8c4b34
100644
(file)
--- a/
withMulklib.c
+++ b/
withMulklib.c
@@
-12,6
+12,22
@@
/* This code is only for x86_64 gcc linux. It is NOT threadsafe. */
/* 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;
/* w00t, I am a three-star-programmer! */
void ***dereferencedPointer;
void ***lastDereferencedPointer;
@@
-78,8
+94,7
@@
void*** lazy_alloc (void* (*calculate) (void*), void* opt) {
lockedPointer++;
dereferencedPointer++;
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;
en->function = calculate;
en->argument = opt;
en->dereferencedPointer = ret;
@@
-219,7
+234,7
@@
inline void initializeSignalHandler () {
}
void *calculateLazy24 (void* bla) {
}
void *calculateLazy24 (void* bla) {
- int* ret = (int*)
malloc
(sizeof(int));
+ int* ret = (int*)
slice_alloc
(sizeof(int));
*ret = 42;
return (void*) ret;
}
*ret = 42;
return (void*) ret;
}