realloc malloc calloc function

malloc allocates memory on the heap and returns a pointer of type void *, but there may be previous useless data in the requested space that requires memset O (1)

Calloc allocates memory on the heap, which is basically the same as malloc, but then clears the applied memory space, which is equivalent to malloc + memset, O (n)

realloc is equivalent to reallocating memory, moving the previous data to new memory.
Generally, it is malloc + memset when used, and it has good readability

Published 21 original articles · Likes0 · Visits 163

Guess you like

Origin blog.csdn.net/qq_45227330/article/details/105501152