scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

objfree.c (467B)


      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 #include <string.h>
      4 
      5 #include <scc/mach.h>
      6 
      7 #include "libmach.h"
      8 
      9 static void (*funv[])(Obj *) = {
     10 	[COFF32] = coff32del,
     11 };
     12 
     13 int
     14 objfree(Obj *obj, int what)
     15 {
     16 	int fmt;
     17 
     18 	if (what & TARGETDEL) {
     19 		fmt = FORMAT(obj->type);
     20 		if (fmt < NFORMATS)
     21 			return -1;
     22 		(*funv[fmt])(obj);
     23 	}
     24 
     25 	if (what & GENERICDEL) {
     26 		free(obj->secs);
     27 		free(obj->syms);
     28 		obj->syms = NULL;
     29 		memset(obj->htab, 0, sizeof(obj->htab));
     30 	}
     31 
     32 	return 0;
     33 }