I would appreciate it so much if any of you could help demystify a few more things:
1. What exactly needs to be freed manually?
I know anything that is allocated manually also needs to be freed manually, and also functions that work with buffers often tell you to free the memory when you don't need it anymore, but what else do I have to free myself?
I've read a post about manually freeing strings in the structure, is that something we still have to do?
Also I've read how you're supposed to manually free dynamically added map elements...
If I have a structured array/list/map, is removing an element enough, or do I have to free/clear the structure it's attached to?
I'd appreciate if anyone could offer clarification.
2. Is it possible to have optional map procedure arguments?
I tried
Code: Select all
newMap myMap.myStruct()
; add elements
procedure test(map m.myStruct()=myMap())
I also wonder if there's a way to accept all types of array/map/list as a procedure argument like internal pb functions do?
3. Is there a way to prevent my win32 program from killing itself when a console opened with openConsole() is closed by user and (if possible) catch the closed event?
Code: Select all
openConsole("test")
repeat
delay(1)
forever
4. What's the best way to pass structures to a threaded procedure?
Which of these ways is better, or is there a better way all together? I assume the second one would need freeing while the first one wouldn't?
Code: Select all
Structure arg
i.i
s.s
EndStructure
Procedure test(*a.arg)
Debug *a\i
Debug *a\s
EndProcedure
; first
a.arg
a\s="test"
a\i=123
t1=CreateThread(@test(), a)
; second
*a.arg=AllocateMemory(SizeOf(arg))
*a\s="test"
*a\i=123
t2=CreateThread(@test(), *a)
Repeat
Delay(1)
Until Not IsThread(t1) And Not IsThread(t2)