Branch: Tag:

1998-03-03

1998-03-03 11:24:48 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

DEBUG_MALLOC added

Rev: src/acconfig.h:1.12
Rev: src/array.c:1.23
Rev: src/array.h:1.7
Rev: src/block_alloc.h:1.1
Rev: src/builtin_functions.c:1.61
Rev: src/dmalloc.h:1.1
Rev: src/dynamic_buffer.c:1.6
Rev: src/dynamic_buffer.h:1.4
Rev: src/dynamic_load.c:1.23
Rev: src/global.h:1.12
Rev: src/interpret.h:1.16
Rev: src/language.yacc:1.51
Rev: src/las.c:1.40
Rev: src/las.h:1.9
Rev: src/lex.c:1.35
Rev: src/main.c:1.28
Rev: src/mapping.c:1.26
Rev: src/mapping.h:1.5
Rev: src/module.c:1.7
Rev: src/modules/Image/colortable.c:1.29
Rev: src/modules/Image/encodings/gif.c:1.21
Rev: src/modules/Image/encodings/png.c:1.2
Rev: src/modules/Image/font.c:1.22
Rev: src/modules/Image/image.c:1.71
Rev: src/modules/files/efuns.c:1.41
Rev: src/modules/files/file.c:1.62
Rev: src/modules/files/socket.c:1.19
Rev: src/modules/spider/dumudp.c:1.29
Rev: src/modules/spider/spider.c:1.51
Rev: src/modules/system/system.c:1.34
Rev: src/multiset.h:1.4
Rev: src/object.c:1.30
Rev: src/object.h:1.12
Rev: src/peep.c:1.16
Rev: src/pike_memory.c:1.5
Rev: src/pike_memory.h:1.2
Rev: src/pike_types.c:1.27
Rev: src/pike_types.h:1.6
Rev: src/program.c:1.47
Rev: src/program.h:1.23
Rev: src/stralloc.c:1.19
Rev: src/stralloc.h:1.10
Rev: src/svalue.h:1.10

1: + #define INIT_BLOCK(X) + #define EXIT_BLOCK(X) + #define BLOCK_ALLOC(DATA,BSIZE) \ +  \ + struct PIKE_CONCAT(DATA,_block) \ + { \ +  struct PIKE_CONCAT(DATA,_block) *next; \ +  struct DATA x[BSIZE]; \ + }; \ +  \ + static struct PIKE_CONCAT(DATA,_block) *PIKE_CONCAT(DATA,_blocks)=0; \ + static struct DATA *PIKE_CONCAT3(free_,DATA,s)=0; \ +  \ + struct DATA *PIKE_CONCAT(alloc_,DATA)(void) \ + { \ +  struct DATA *tmp; \ +  if(!PIKE_CONCAT3(free_,DATA,s)) \ +  { \ +  struct PIKE_CONCAT(DATA,_block) *n; \ +  int e; \ +  n=(struct PIKE_CONCAT(DATA,_block) *)malloc(sizeof(struct PIKE_CONCAT(DATA,_block))); \ +  if(!n) \ +  { \ +  fprintf(stderr,"Fatal: out of memory.\n"); \ +  exit(17); \ +  } \ +  n->next=PIKE_CONCAT(DATA,_blocks); \ +  PIKE_CONCAT(DATA,_blocks)=n; \ +  \ +  for(e=0;e<BSIZE;e++) \ +  { \ +  n->x[e].next=PIKE_CONCAT3(free_,DATA,s); \ +  PIKE_CONCAT3(free_,DATA,s)=n->x+e; \ +  } \ +  } \ +  \ +  tmp=PIKE_CONCAT3(free_,DATA,s); \ +  PIKE_CONCAT3(free_,DATA,s)=tmp->next; \ +  INIT_BLOCK(tmp); \ +  return tmp; \ + } \ +  \ + inline void PIKE_CONCAT(free_,DATA)(struct DATA *d) \ + { \ +  EXIT_BLOCK(d); \ +  d->next=PIKE_CONCAT3(free_,DATA,s); \ +  PIKE_CONCAT3(free_,DATA,s)=d; \ + } \ +  \ + void PIKE_CONCAT3(free_all_,DATA,_blocks)(void) \ + { \ +  struct PIKE_CONCAT(DATA,_block) *tmp; \ +  while((tmp=PIKE_CONCAT(DATA,_blocks))) \ +  { \ +  PIKE_CONCAT(DATA,_blocks)=tmp->next; \ +  free((char *)tmp); \ +  } \ +  PIKE_CONCAT(DATA,_blocks)=0; \ + } \      Newline at end of file added.