开发者

local and dynamic allocating

开发者 https://www.devze.com 2022-12-22 06:38 出处:网络
I have a tree and I want to release the allocated memory, but I face a problem thata pointer mayrefers to a variable tha开发者_如何学JAVAt isn\'t dynamically allocated,so how to know wether this point

I have a tree and I want to release the allocated memory, but I face a problem that a pointer may refers to a variable tha开发者_如何学JAVAt isn't dynamically allocated,so how to know wether this pointer refers to dynamic a variable or not


This is compiler-specific. You may compare given pointer with pointer to a local variable. Result interpretation depends on the way compiler implements heap and stack. Generally, for given compiler, stack pointer is always less (or greater) than heap pointer. In any case, THIS IS BAD DESIGN. This may not work if pointer belongs to another heap (for example, allocated in another Dll).

0

精彩评论

暂无评论...
验证码 换一张
取 消