Find size of a function in C

后端 未结 9 1759
别跟我提以往
别跟我提以往 2020-12-10 16:37

I am learning function pointers,I understand that we can point to functions using function pointers.Then I assume that they stay in memory.Do they stay in stack or heap?Can

9条回答
  •  -上瘾入骨i
    2020-12-10 16:55

    C has no garbage collector. Having a pointer to something doesn't make it stay in memory.

    Functions are always in memory, whether or not you use them, whether or not you keep a pointer to them.

    Dynamically allocated memory can be freed, but it has nothing to do with keeping a pointer to it. You shouldn't keep pointer to memory you have freed, and you should free it before losing the pointer to it, but the language doesn't do it automatically.

提交回复
热议问题