scc

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

objfree.c (444B)


      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 extern delfun_t delv[];
     10 
     11 int
     12 objfree(Obj *obj, int what)
     13 {
     14 	int fmt;
     15 	delfun_t fn;
     16 
     17 	if (what & TARGETDEL) {
     18 		fmt = FORMAT(obj->type);
     19 		if (fmt < NFORMATS)
     20 			return -1;
     21 		fn = delv[fmt];
     22 		(*fn)(obj);
     23 	}
     24 
     25 	if (what & GENERICDEL) {
     26 		free(obj->symbols);
     27 		obj->symbols = NULL;
     28 		memset(obj->htab, 0, sizeof(obj->htab));
     29 	}
     30 
     31 	return 0;
     32 }