Added another examples for Chapter 9
This commit is contained in:
16
chp9/test_malloc.c
Normal file
16
chp9/test_malloc.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
int main(void) {
|
||||
char *buf = (char *)malloc(256);
|
||||
if (!buf) {
|
||||
perror("malloc");
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t size = malloc_usable_size(buf);
|
||||
printf("%d\n", size);
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user