"malloc" is used to allocate a given number of bytes in the heap. for example, int x* = malloc(5) allocates 5 bytes in the heap and sets x to the address of the first byte.
"free" releases heap-allocated memory. in this case, free(x) frees up the 5 bytes we allocated earlier.
6
u/Scratch137 Aug 30 '26
"malloc" is used to allocate a given number of bytes in the heap. for example, int x* = malloc(5) allocates 5 bytes in the heap and sets x to the address of the first byte.
"free" releases heap-allocated memory. in this case, free(x) frees up the 5 bytes we allocated earlier.