• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Static data?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Static data?


  • Subject: Re: Static data?
  • From: Markus Hitter <email@hidden>
  • Date: Wed, 7 Jul 2004 10:12:33 +0200

Am 07.07.2004 um 00:26 schrieb Markian Hlynka:

The advantage of static or automatic storage (as opposed to heap allocated storage) is that you do *not* need to handle errors, cause there will be none, ...
The errors appear at app launch time. Even more likely as malloc(), as there are tighter limitations.

I do not know what you mean with "even more likely" -- but for the coder it's certainly better just to have the OS refuse to load the program if ...

That's the *ouch* user-experience. ;-)

in C++ I'd do

int*** foo;
foo = new foo**[1024]
//now do a for loop and allocate foo[i]= new foo*[1024]
//and then another for loop for foo[i][j] = new foo[1024]

is there a better/more proper way to do this in C++?

You can replace new with malloc() to make this work in C and Obj-C, too.

What about in C? obviously I could just do
int* foo = malloc(3*1024*sizeof(int))
and then do the indices manually.

is there a better/proper way to do any/either of these?

Not one I'm aware of.


To be honest, I sometimes had the wish to create a multi-dimensional, dynamically sized array at runtime like:


	int foo[i][j][k] = malloc(sizeof(foo));

but this won't happen. It's a limitation of the C language and as we live for 20 years with this limitation and it's workarounds (your guesses are correct) now, this probably won't change soon.

I can't remember a case where I ran into limits with big static arrays, however. Each time I process noteworthy amounts of data, there is the urgent need to do size the storage dynamically. Or to split the data into smaller chunks dynamically.


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.


References: 
 >Static data? (From: "Christopher Beck" <email@hidden>)
 >Re: Static data? (From: Pavol Markovic <email@hidden>)
 >Re: Static data? (From: Markus Hitter <email@hidden>)
 >Re: Static data? (From: Markus Hitter <email@hidden>)
 >Re: Static data? (From: Allan Odgaard <email@hidden>)
 >Re: Static data? (From: Markian Hlynka <email@hidden>)

  • Prev by Date: Re: Static data?
  • Next by Date: Re: FYI: Xcode "Find In Project" Regular Expression syntax
  • Previous by thread: Re: Static data?
  • Next by thread: Re: Static data?
  • Index(es):
    • Date
    • Thread