In Windows, is there a difference between the winAPI GlobalAlloc_() and the PB proc AllocateMemory()?
I see lots of people using GlobalAlloc_() in their examples but don't see any obvious differences..
Thanks!
[edit]
Ok, so I do see one difference.. Flags aren't supported by AllocateMemory() like : GlobalAlloc_(#GMEM_FIXED | #GMEM_ZEROINIT, #BUFFERSIZE)
... but is that the only difference?
GlobalAlloc_() verses AllocateMemory()?
GlobalAlloc_() verses AllocateMemory()?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Re: GlobalAlloc_() verses AllocateMemory()?
The diffrent is, that you must give AllocateMemory() a nr and globalAlloc gives you a "nr" (ok, it is a adress, but it is also the "handle" for the memory)
When you programm a routine, that is in the window-callback, timer and so on, you can get problems, that a routine can called twice and so you get a already allocate error.
When you programm a routine, that is in the window-callback, timer and so on, you can get problems, that a routine can called twice and so you get a already allocate error.
Re: GlobalAlloc_() verses AllocateMemory()?
Problems when using GlobalAlloc_() or PB's AllocateMemory()?GPI wrote:When you programm a routine, that is in the window-callback, timer and so on, you can get problems, that a routine can called twice and so you get a already allocate error.
Thanks for the info!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
- tinman
- PureBasic Expert

- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
Re: GlobalAlloc_() verses AllocateMemory()?
PB's AllocateMemory() because you must specify a bank number. It's a pain when you are working with (lots of) dynamic memory allocations because not only do you need to keep track of the pointer to the memory (or course, you'd need to do this with GlobalAlloc_() anyway) but you must also keep track of what memory banks you have used.Karbon wrote:Problems when using GlobalAlloc_() or PB's AllocateMemory()?GPI wrote:When you programm a routine, that is in the window-callback, timer and so on, you can get problems, that a routine can called twice and so you get a already allocate error.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
Got ya. Thanks!!!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
GlobalAlloc_() is an old, outdated function, which is only still there for
backward compatibility and for some stuff like clipboard management.
You should use the Heap functions like HeapAlloc_() and so on, because
they are faster than GlobalAlloc_(). PB's AllocateMemory() uses the Heap
stuff if i'm not wrong, so it should be a bit faster than GlobalAlloc_().
Timo
backward compatibility and for some stuff like clipboard management.
You should use the Heap functions like HeapAlloc_() and so on, because
they are faster than GlobalAlloc_(). PB's AllocateMemory() uses the Heap
stuff if i'm not wrong, so it should be a bit faster than GlobalAlloc_().
Timo
quidquid Latine dictum sit altum videtur