Re: Static data?
Re: Static data?
- Subject: Re: Static data?
- From: Markus Hitter <email@hidden>
- Date: Sat, 3 Jul 2004 11:26:42 +0200
Am 03.07.2004 um 08:59 schrieb Pavol Markovic:
... Better to use dynamic allocation in such cases.
On 1.7.2004, at 15:42, Christopher Beck wrote:
I am having trouble getting some C++ code to compile and build with
Xcode. It seems to be an issue with the large amount of static data
that I need for the code.
Better use dynamic allocation for any noteworthy amount of data. It's
just a few additional characters (same for C, Obj-C and C++):
{
long data[10000000];
... (insert code here) ...
}
->
{
long* data = malloc(100000000 * sizeof(long));
... (insert code here) ...
free(data);
}
This gives you the same level of memory handling. Additionally, you
have the chance to handle allocation errors, rezize the allocated array
(realloc()) and to release the array before the function returns.
The weird thing is that I can get the code to compile with gcc on
cygwin without a problem.
Non-dynamic data is allocated on the stack. Stack size is limited and
varies from OS to OS.
Cheers,
Markus
- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.