shithub: scc

ref: 6d5cccdbfa78d757b07efa64195f49a5db7e46e1
dir: /src/libmach/objfree.c/

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

#include <scc/mach.h>

#include "libmach.h"

static void (*funv[])(Obj *) = {
	[COFF32] = coff32del,
};

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

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

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

	return 0;
}