Hello,
When FreeMemory() receive a Null MemoryID we get an compiler ERROR !
I think this function should be capable to handle the Null MemoryID situation internally.
Regards
Guimauve
FreeMemory()
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
The program proceeds normally when the debugger is off but does not return a useful result (the result is non-zero).
Granted there are a lot of functions that should fail more gracefully it's completely within our power to check whether the pointer being passed is null or not before it's passed to the function.
Granted there are a lot of functions that should fail more gracefully it's completely within our power to check whether the pointer being passed is null or not before it's passed to the function.
Ok I will create my user procedure like this.
By the way, the FreeMemory() just tell the system : This memoryID is not used anymore.
Anyway, I let Fred to take care of this request.
Regards
Guimauve
Code: Select all
Procedure FreeMemoryEx(MemoryID)
If MemoryID <> #Null
FreeMemory(MemoryID)
EndIf
EndProcedure
Anyway, I let Fred to take care of this request.
Regards
Guimauve
If the memory crashes, you use bad code. IsMemory can solve the crash butakj wrote:Alternatively, what about a new IsMemory() command to check whether the memory reference is valid?
This may also be useful for preventing invalid memory crashes.
not your bad code

Better is to change the code
yust my two cents
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

i handle it like this:
to check if the memory is still available or freed. (is freed a word
)
Code: Select all
If mem
FreeMemory(mem)
mem = 0
EndIf
