[C / C ++ Memory Memory] []

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

malloc、realloc、calloc、free by C

  • Be sure to determine whether the successful application of space
  • calloc After the success of the application memory is initialized to 0.
  • malloc, reallocDoes not initialize memory after the application is successful.
  • After the dynamic memory allocation must freefree up space.
void *__cdecl malloc(size_t _Size);
void *__cdecl calloc(size_t _Count, size_t _Size);
void *__cdecl realloc(void *_Block, size_t _Size);

char *ptr;
ptr = (char *)malloc(sizeof(char) * ArrLng);
ptr = (char *)calloc(ArrLng, sizeof(char));
ptr = (char *)realloc(ptr, sizeof(char) * ArrLng);
free(ptr);

Heap head
stack stack


Here Insert Picture Description

new、delete by C++


Guess you like

Origin blog.csdn.net/qq_35689096/article/details/93410623