scc

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

commit ab0260897a78c5ec8d7cb2ed441c6d0af2c567c5
parent 45aeb7595a61f2f6b015a0beb08d99e520e20ffa
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 23 Aug 2019 18:33:01 +0100

[libmach] Don't free obj in objdel()

This makes easier to use objdel for strip, because it doesn't
make sense to have relocation information in the generic part
when we do not have taget information.

Diffstat:
Msrc/libmach/coff32/coff32del.c | 1+
Msrc/libmach/coff32/coff32strip.c | 1+
Asrc/libmach/objdel.c | 18++++++++++++++++++
Dsrc/libmach/objfree.c | 15---------------
4 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/src/libmach/coff32/coff32del.c b/src/libmach/coff32/coff32del.c @@ -20,4 +20,5 @@ coff32del(Obj *obj) obj->data = NULL; objdel(obj); + free(obj); } diff --git a/src/libmach/coff32/coff32strip.c b/src/libmach/coff32/coff32strip.c @@ -34,6 +34,7 @@ coff32strip(Obj *obj) coff->ents = NULL; coff->rels = NULL; coff->lines = NULL; + objdel(obj); return 0; } diff --git a/src/libmach/objdel.c b/src/libmach/objdel.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <scc/mach.h> + +#include "libmach.h" + +void +objdel(Obj *obj) +{ + free(obj->secs); + free(obj->syms); + + obj->syms = NULL; + obj->secs = NULL; + memset(obj->htab, 0, sizeof(obj->htab)); +} diff --git a/src/libmach/objfree.c b/src/libmach/objfree.c @@ -1,15 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <scc/mach.h> - -#include "libmach.h" - -void -objdel(Obj *obj) -{ - free(obj->secs); - free(obj->syms); - free(obj); -}