+__thread void * baseptr=NULL;
+
+__thread int spaceleft=0;
+
+#define MBLOCK 65536
+#define MLOW 1000
+
+void * MLPMALLOC(int size) {
+ // printf("%d\n",size);
+ if (spaceleft<MLOW) {
+ baseptr=malloc(MBLOCK);
+ spaceleft=MBLOCK;
+ }
+ if (size>spaceleft) {
+ return malloc(size);
+ } else {
+ //rount size up
+ size=(size+7)&~7;
+ char *charbase=(char *)baseptr;
+ baseptr=(void *)(charbase+size);
+ spaceleft-=size;
+ return charbase;
+ }
+}