|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T p ┃
Length: 1249 (0x4e1) Types: TextFile Names: »pmalloc.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/elm/src/pmalloc.c«
/** pmalloc.c **/ /** This routine contains a cheap permanent version of the malloc call to speed up the initial allocation of the weedout headers and the uuname data. This routine is originally from Jim Davis of HP Labs, with some mods by me. **/ #include <stdio.h> #include "defs.h" /*VARARGS0*/ char *pmalloc(size) int size; { /** return the address of a specified block **/ static char *our_block = NULL; static int free_mem = 0; char *return_value, *malloc(); /** if bigger than our threshold, just do the real thing! **/ if (size > PMALLOC_THRESHOLD) return(malloc(size)); /** if bigger than available space, get more, tossing what's left **/ if (size > free_mem) { if ((our_block = malloc(PMALLOC_BUFFER_SIZE)) == NULL) { fprintf(stderr, "\n\r\n\rCouldn't malloc %d bytes!!\n\r\n\r", PMALLOC_BUFFER_SIZE); leave(); } our_block += 4; /* just for safety, don't give back true address */ free_mem = PMALLOC_BUFFER_SIZE-4; } return_value = our_block; /* get the memory */ size = ((size+3)/4)*4; /* Go to quad byte boundary */ our_block += size; /* use it up */ free_mem -= size; /* and decrement */ return( (char *) return_value); }