Determine size of dynamically allocated memory in C

后端 未结 15 2295
孤街浪徒
孤街浪徒 2020-11-22 06:15

Is there a way in C to find out the size of dynamically allocated memory?

For example, after

char* p = malloc (100);

Is there

15条回答
  •  既然无缘
    2020-11-22 07:02

    I would expect this to be implementation dependent.
    If you got the header data structure, you could cast it back on the pointer and get the size.

提交回复
热议问题