shithub: scc

ref: a8d4f208d8e94b207c1625fa0008a9f247635dd2
dir: /src/libmach/objfree.c/

View raw version
#include <stdio.h>
#include <stdlib.h>

#include <scc/mach.h>

#include "libmach.h"

extern delfun_t delv[];

void
objfree(Obj *obj, int what)
{
	int fmt;
	delfun_t fn;

	if (what & TARGETDEL) {
		fmt = FORMAT(obj->type);
		if (fmt < NFORMATS)
			return -1;
		fn = delv[fmt];
		(*fn)(obj);
	}

	if (what & GENERICDEL) {
		free(obj->symbols);
		obj->symbols = NULL;
		memset(obj->htab, 0, sizeof(obj->htab));
	}
}