summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2024-05-16 14:03:57 -0700
committerMatthew Sotoudeh <matthew@masot.net>2024-05-16 14:03:57 -0700
commit54c09d54c0c170f1369751f8bf5a8a0b771a167c (patch)
treee73ab0e8b25602f8c7233ea7794020224fae92aa
parent940716fa2fa134a75d2ef34b41991c1c1c14735a (diff)
reorganize
-rw-r--r--Makefile7
-rw-r--r--examples/main.c (renamed from main.c)0
-rw-r--r--magic_buddy/buddy.h (renamed from buddy.h)0
-rw-r--r--magic_buddy/magic_buddy.c (renamed from magic_buddy.c)3
4 files changed, 6 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 35aba2c..e856534 100644
--- a/Makefile
+++ b/Makefile
@@ -2,12 +2,13 @@
CFLAGS += -g
CFLAGS += -O3
+CFLAGS += -I./magic_buddy
# CFLAGS += -fsanitize=address
-all: build/magic
+all: build/examples/main
-build/magic: main.c magic_buddy.c
- @ mkdir -p build
+build/examples/%: examples/%.c magic_buddy/magic_buddy.c
+ @ mkdir -p $(dir $@)
$(CC) $(CFLAGS) $^ -o $@
clean:
diff --git a/main.c b/examples/main.c
index a288f1c..a288f1c 100644
--- a/main.c
+++ b/examples/main.c
diff --git a/buddy.h b/magic_buddy/buddy.h
index c8778d6..c8778d6 100644
--- a/buddy.h
+++ b/magic_buddy/buddy.h
diff --git a/magic_buddy.c b/magic_buddy/magic_buddy.c
index 868bfd7..80bc069 100644
--- a/magic_buddy.c
+++ b/magic_buddy/magic_buddy.c
@@ -201,7 +201,8 @@ void *reallocate(void *old, size_t old_size, size_t new_size,
struct buddy *state) {
if (new_size == 0) return liberate(old, old_size, state), (void*)0;
- if (size < sizeof(struct free_block)) size = sizeof(struct free_block);
+ if (new_size < sizeof(struct free_block))
+ new_size = sizeof(struct free_block);
size_t old_logsize = size2log(old_size, 1);
size_t new_logsize = size2log(new_size, 1);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback