Add arena_free()

This commit is contained in:
Ole Morud
2023-06-04 12:33:44 +02:00
committed by Ole Morud
parent 45e6023d42
commit e5fa743d85
4 changed files with 160 additions and 55 deletions

View File

@@ -1,6 +1,28 @@
CC := gcc
CFLAGS := -g -O3 -std=c2x -Wall -Wextra -Wpedantic -Werror -Iinclude
all:
BUILD ?= debug
COMPILER ?= gcc
# ==== set compiler flags ====
# credits Maxim Egorushkin:
# https://stackoverflow.com/questions/48791883/best-practice-for-building-a-make-file/48793058#48793058
CC := $(COMPILER)
# -fsanitize={address,undefined}
CFLAGS.gcc.debug := -Og -ggdb -pg -fsanitize=address -fno-omit-frame-pointer
CFLAGS.gcc.release := -O3 -g -march=native -DNDEBUG
CFLAGS.gcc := -fanalyzer
CFLAGS.clang.debug :=-O0 -g3 -DBACKTRACE -rdynamic
CFLAGS.clang.release :=-O3 -g -march=native -DNDEBUG
CFLAGS.clang :=
CFLAGS := ${CFLAGS.${COMPILER}} ${CFLAGS.${COMPILER}.${BUILD}} \
-Iinclude \
-std=c2x \
-Wall -Wextra -Wpedantic -Werror
BUILD_DIR := build
BIN_DIR := lib
@@ -9,6 +31,8 @@ TEST_DIR := test
OBJS := $(BUILD_DIR)/arena.o
FPIC_OBJS := $(BUILD_DIR)/fpic/arena.o
all : static
static : $(BIN_DIR)/libarena.a
dynamic : $(BIN_DIR)/libarena.so
@@ -22,7 +46,7 @@ $(BIN_DIR)/libarena.a : $(OBJS) | $(BIN_DIR)
ar cr $@ $^
$(BIN_DIR)/libarena.so : $(FPIC_OBJS) | $(BIN_DIR)
$(CC) -shared -o $@ $^
$(CC) -o $@ -shared $(CFLAGS) $^
$(BUILD_DIR)/%.o : src/%.c | $(BUILD_DIR)
$(CC) -o $@ -c $(CFLAGS) $<