summaryrefslogtreecommitdiff
path: root/magic_buddy
diff options
context:
space:
mode:
Diffstat (limited to 'magic_buddy')
-rw-r--r--magic_buddy/magic_buddy.c3
-rw-r--r--magic_buddy/magic_buddy.h2
2 files changed, 3 insertions, 2 deletions
diff --git a/magic_buddy/magic_buddy.c b/magic_buddy/magic_buddy.c
index c6283d8..9deaa8f 100644
--- a/magic_buddy/magic_buddy.c
+++ b/magic_buddy/magic_buddy.c
@@ -197,7 +197,7 @@ static void *_naive_reallocate(void *old, size_t old_size, size_t new_size,
return new;
}
-void *reallocate(void *old, size_t old_size, size_t new_size,
+void *reallocate(void *old, size_t new_size, size_t old_size,
struct buddy *state) {
if (new_size == 0) return liberate(old, old_size, state), (void*)0;
@@ -316,6 +316,7 @@ int shrink_buddy(size_t new_size, struct buddy *state) {
}
void move_buddy(struct buddy *new_state, struct buddy *old_state) {
+ if (new_state == old_state) return;
memcpy(new_state, old_state, sizeof(struct buddy));
for (size_t i = 0; i < ADDRESS_BITS; i++) {
if (!new_state->avail[i]) continue;
diff --git a/magic_buddy/magic_buddy.h b/magic_buddy/magic_buddy.h
index c8778d6..a25ceb7 100644
--- a/magic_buddy/magic_buddy.h
+++ b/magic_buddy/magic_buddy.h
@@ -30,7 +30,7 @@ void debug_buddy(struct buddy *state);
// Simulates @new = allocate, memcpy(@new, @old), free(@old), with some
// optimizations for cases where the reallocation can be done in place.
-void *reallocate(void *old, size_t old_size, size_t new_size,
+void *reallocate(void *old, size_t new_size, size_t old_size,
struct buddy *state);
// Attempts to reserve a range [@start,@start+@size).
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback