Realloc is not resizing array of pointers

后端 未结 2 1308
死守一世寂寞
死守一世寂寞 2020-12-21 15:45

I keep passing in and returning the dirs_later_array. When I get to \"new_size=...\" in the else block, I end up with new_size of 2 the second time around. So far so good.

2条回答
  •  渐次进展
    2020-12-21 16:25

    Operator sizeof is a compile time feature and it only checks the static size of an expression. So for pointer it only returns the size of that pointer which is 4 on your platform. sizeof does not measure the size of a dynamically allocated data. There is no standard feature in C to get the size of dynamically allocated data.

提交回复
热议问题