• 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: Allan Odgaard <email@hidden>
  • Date: Tue, 6 Jul 2004 22:56:53 +0200

On 6. Jul 2004, at 22:24, Markus Hitter wrote:

There are cases where this transformation cannot happen, like:
    long data[1024][1024];
->
    data = ...?
From the C-FAQ (<http://www.faqs.org/faqs/C-faq/faq/>) 6.16:
[...]

But this is not the same thing. It has a different memory layout (which may be important if you manipulate image data or similar), it looses the extra type info about array sizes (which could be deduced using sizeof() or template functions) and it require extra code to deal with alloc/free of each row plus probably worse cache performance and memory fragmentation (overhead). So while this might be used in some circumstances, it's not a general "transformation" from static to dynamic data of n dimensional arrays (as it could easily break programs relying on sizeof(), the continuos memory layout, or programs which use template functions to work on the array data).


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 it makes memory requirements which it cannot fulfill, rather than the need to check every single trivial allocation (for which there would perhaps anyway be no graceful way to handle an allocation fault).


Oh, and if you are going to reply publicly to a private letter, you should quote all points made in that letter (and consider if there really is a need to cc the list)!
_______________________________________________
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.



  • Follow-Ups:
    • Re: Static data?
      • From: Markian Hlynka <email@hidden>
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>)

  • Prev by Date: Re: Static data?
  • Next by Date: Selecting a cell within NSTableView
  • Previous by thread: Re: Static data?
  • Next by thread: Re: Static data?
  • Index(es):
    • Date
    • Thread