From 243a37719b389c6d85b7d4230081cb70d5b74a22 Mon Sep 17 00:00:00 2001 From: Frank Kotler Date: Sat, 6 Sep 2003 05:48:16 +0000 Subject: [PATCH] nasm_malloc-ize Martin's outelf.c stabs stuff --- output/outelf.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/output/outelf.c b/output/outelf.c index c304f0b1..349b15f5 100644 --- a/output/outelf.c +++ b/output/outelf.c @@ -1275,14 +1275,17 @@ void stabs_init(struct ofmt *of,void *id,FILE *fp,efunc error) void stabs_linenum(const char *filename,long linenumber,long segto) { if (!stabs_filename) { - stabs_filename = (char *)malloc(strlen(filename)+1); + stabs_filename = (char *)nasm_malloc(strlen(filename)+1); strcpy(stabs_filename,filename); } else { if (strcmp(stabs_filename,filename)) { /* yep, a memory leak...this program is one-shot anyway, so who cares... in fact, this leak comes in quite handy to maintain a list of files encountered so far in the symbol lines... */ - stabs_filename = (char *)malloc(strlen(filename)+1); + + /* why not nasm_free(stabs_filename); we're done with the old one */ + + stabs_filename = (char *)nasm_malloc(strlen(filename)+1); strcpy(stabs_filename,filename); } } @@ -1311,7 +1314,7 @@ void stabs_output(int type,void *param) s=(struct symlininfo *)param; if (strcmp( s->name,".text")) return; /* we are only interested in the text stuff */ numlinestabs++; - el=(struct linelist *)malloc(sizeof(struct linelist)); + el=(struct linelist *)nasm_malloc(sizeof(struct linelist)); el->info.offset=s->offset; el->info.section=s->section; el->info.name=s->name; @@ -1352,7 +1355,7 @@ void stabs_generate(void) ptr=stabslines; - allfiles = (char **)malloc(numlinestabs*sizeof(char *)); + allfiles = (char **)nasm_malloc(numlinestabs*sizeof(char *)); for (i=0;inext; } strsize=1; - fileidx = (int *)malloc(numfiles*sizeof(int)); + fileidx = (int *)nasm_malloc(numfiles*sizeof(int)); for (i=0;in_desc=numstabs; - free(allfiles); - free(fileidx); + nasm_free(allfiles); + nasm_free(fileidx); stablen = (sptr-sbuf); stabrellen=(rptr-rbuf); @@ -1471,11 +1474,11 @@ void stabs_cleanup() { while (ptr) { del=ptr; ptr=ptr->next; - free(del); + nasm_free(del); } - if (stabbuf) free(stabbuf); - if (stabrelbuf) free(stabrelbuf); - if (stabstrbuf) free(stabstrbuf); + if (stabbuf) nasm_free(stabbuf); + if (stabrelbuf) nasm_free(stabrelbuf); + if (stabstrbuf) nasm_free(stabstrbuf); } #endif /* OF_ELF */ -- 2.11.4.GIT