Skip to content

Commit

Permalink
fix free_pair to free the whole buffer, not just the first half, and …
Browse files Browse the repository at this point in the history
…make test_allocate_pair actually call it
  • Loading branch information
mikeash committed Jan 25, 2012
1 parent f373a52 commit 0f050b5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion AllocatePair.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void *allocate_pair(size_t howmuch)

void free_pair(void *ptr, size_t howmuch)
{
vm_deallocate(mach_task_self(), (vm_address_t)ptr, howmuch);
vm_deallocate(mach_task_self(), (vm_address_t)ptr, howmuch * 2);
}

size_t get_page_size(void)
Expand Down Expand Up @@ -94,6 +94,8 @@ static void test_size(size_t howmuch)
buf[howmuch + i] = nrand48(seed);
if(memcmp(buf, buf + howmuch, howmuch) != 0)
fprintf(stderr, "FAIL: writing to second half didn't update first half with size %lu\n", (long)howmuch);

free_pair(buf, howmuch);
}

void test_allocate_pair(void)
Expand Down

0 comments on commit 0f050b5

Please sign in to comment.