feat: update structure

This commit is contained in:
2024-01-22 14:27:40 +08:00
parent 7836c9185c
commit 3544a28a2e
559 changed files with 120846 additions and 4102 deletions

View File

@@ -0,0 +1,35 @@
#include "mymalloc.h"
#include <stdio.h>
void testalloc(long size, char *ptrname, char **ptr) {
printf("\nAllocating %ld bytes to %s\n", size, ptrname);
*ptr = mymalloc(size);
if (*ptr == NULL)
printf("Allocation failed.\n");
print_memlist();
}
void testfree(char *ptr, char *ptrname) {
printf("\nFreeing %s\n", ptrname);
myfree(ptr);
print_memlist();
}
int main() {
char *ptr1, *ptr2, *ptr3, *ptr4, *ptr5;
testalloc(4, "ptr1", &ptr1);
testalloc(32, "ptr2", &ptr2);
testalloc(4, "ptr3", &ptr3);
testfree(ptr2, "ptr2");
testalloc(24, "ptr2", &ptr2);
testalloc(6, "ptr4", &ptr4);
testfree(ptr2, "ptr2");
testalloc(32, "ptr5", &ptr5);
testfree(ptr1, "ptr1");
testfree(ptr2, "ptr2");
testfree(ptr3, "ptr3");
testfree(ptr4, "ptr4");
testfree(ptr5, "ptr5");
}