?????????????????????????????????е???????????(heap)??????????????????????(stack)?????е?????????????????????????????????ú??????洢???????????????????????????е???????????????????????????????????????????????????????????????????????Щ????????????????????
??????????????????????????????????洢???????????????????????????????С????????????Ч??????????
????malloc??free
????C???????е?malloc??free?????????ж????????????????????????????????????????????????stdlib.h????????
????void *malloc ( size_t size );
????void free ( void *pointer );
????malloc?????????????????洢???з???????????size?????????????????????????????????????????????????????????洢???????????????????????????????????????δ????????洢???????治?????????NULL????????????ú??????ü?????????NULL???????????????÷???????malloc???????????????????????????malloc??????????????????????????????????????????????????????malloc??????????????????????洢???????????????malloc???????void *????????????????????κ?????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????á????????????free??????free?????????????NULL???????malloc??relloc??calloc??????????????????????????????????????free???????NULL????????????κ?Ч????
????calloc??realloc??malloc??????
????calloc??realloc????????£?
????void *calloc ( size_t num_elements?? size_t element_size );
????void *realloc (void *ptr?? size_t new_size );
????calloc??malloc ????????????????????????????????????????0???????????????????????????calloc????????????????????????????????????????Щ?????????????????????????
????realloc???????????????????????????????С?????????????????????С???????????????????*ptr = NULL?????malloc????*ptr??????nuw_size < size??????С*ptr?????????????????β?????????汻??????????????????????????????nuw_size > size????????*ptr?????????????????????β?????????????????????????????β????????棬??????????β????????????????????????С??realloc?????·????????nuw_size??С????棬???????????????????????μ???????????????realloc????????realloc??????????
??????÷??????????
????int *ptr =NULL;
????ptr = (int*)malloc(sizeof(int)*size);
????if (*ptr == NULL)
????{
????strerror(error);
????return;
????}
?????????ж????????size??????洢?????????????????????????????size????????????洢???????????????????????????????????????????????ptr?? ??????????NULL????????????(int*)??????????????????int??????????????????malloc()???????????????????κ???????????????檔sizeof?????????????????????size_t????????????????????????洢?????????????????????????????int??float???????????????洢??????????????????????????????????????????????????????????????????????sizeof????洢???????????????????????????????????????洢size??int?????????檔???????????sizeof?????????????C???????int???????????????????????
????1 int *p1??*p2;
????2  p1 = (int*)malloc(size * sizeof(int));
????3  p2=p1;
????4 ……
????5 free(p1);  /*????free(p2)*/
??????free??????????????????????????????????????????????????????????????????????????????????????????
????malloc?????????p1?????p1???????p2????????p1??p2???????free???????????malloc???????洢??????з????? free?????????????????????????? ?????????????????????????????????ж?????????м?????????
???????????????????????????????
????· ????????????С???顣??????????????Щ??????????????????С?????????伸?????????????????
????· ??????????????檔??????????????飬???????
????· ??????????????????檔???д??????????????????????????????????檔
????· ????????????????????????и????????????????????????????????й?????????з?????????????С???