|
Lim Hock-Chai wrote:
The compiler checking I'm referring to is more like in the source code you do something like this: myField_BasePointer = *null; (from everybody's posting, seems like you should always do dealloc(n) myField_BasePoniter)
No, it's the other way around. If you dealloc myField_BasePointer, you should make sure you null that variable, and any other variable that has a pointer into that heap storage. This is similar to trying to relate deleting a file to clearing the file's name (I think I'm stealing from Scott K here). You are suggesting the rule: "If you clear a variable that holds a file's name, then you should delete the file". A more reasonable rule would be: "If you delete a file, then you should clear any variables that hold the file's name". I can't remember which of these points has already been made in the various versions of this thread. Sorry for any repetitions. - A basing pointer isn't necessarily a pointer to heap storage. You could set the basing pointer to %ADDR of some other field. - The address might be saved in another pointer and still be needed by the application - The DEALLOC has to be done with the original address; if you advance the pointer within your allocated storage, the DEALLOC would not work. p = %alloc(100); for i = 1 to 10; p = p + 1; endfor; dealloc p; <---- this won't work The dealloc will not deallocate the storage because p now points 10 bytes past the original starting address of the allocation.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.