[windev] Memory allocation suggstion...
Roberto Tirabassi
rtirabassi at 3di.it
Fri Aug 7 08:13:10 GMT 2009
Hi All.
This is going to be a very silly question, or a "rookie" one, but since
its free of any fee, I'll do it all the same! :o)
First: we write code that must be compiled on multiple platforms (say
Windows, SunOs, Linux, MacOS, Aix and others) so the code uses as few
"platform specific" functions as we can.
Second: since the code we develop saw its' first light in Windows
version, we used to create a set of wrapper functions that "emulate"
windows methods behavior under other platforms. You can imagine, this
way, that we wrote the "CreateFile" for unix/linux platforms, having
same parameter than the Windows one. In some other cases we simply
decided to create a custom method that decides how to act due to a
#ifdef/#else/#endif internal check.
Third: the code first born in the '80/'90, so many parts of it are still
written in "old style" C.
So... Windows development in the first years of '90, still 16 bit, uses
GlobalAlloc (and so on) and LocalAlloc (and so on) to allocate,
reallocate and free memory, using GlobalLock and LocalLock (and Unlock
functions) to convert Handles into valid pointers. That was needed to
second memory manager swapping activity. When Windows NT was born,
GlobalAlloc, but especially GlobalLock(), loosed a part of it's meaning.
More: Under Unix/LInux platform the old style malloc()/realloc()/free()
functions are doing well their job since from the "beginning of time"
and C++ code has it's own new()/delete() methods to act as needed.
Now... in C standard code for Windows, which
allocation/reallocation/free functions should you use? And why?
Thanks in advance...
Roberto Tirabassi.
--
"La vendetta è un modo pigro di prolungare il proprio dolore"
[Dal film "The Interpreter" di Sidney Pollack]
Skype: roberto.tirabassi
3D Informatica, Via Speranza 35,
40068, S.Lazzaro di Savena - Bologna, Italy
Voice: +39051450844, Fax: +39051451942
WWW: https://www.3di.it
Documentation: https://www.3di.it/manuali/ - http://wiki.3di.it
FTP: ftp://ftp@ftp.3di.it, Download:/3di, Upload:/incoming
--
More information about the Windev
mailing list