Re: How to reduce Zero Initialised region.



Ajai Jose wrote:
Hi ,
I work on an ARM processor based embedded system. Code is mainly in
C language. The project has a huge source base. We are supposed to
optimise it. Most datastructures are declared as static and which
directly go into the Zero Initialised region. We need to cut the size
of this ZI region by at least 30%.
The one way i see of doing this is by removing these static arrays
and passing a pointer to the data structure whenever required. but
since these global arrays are used through out the code. A re-write
seems inevitable!

two questions I had.
1. Am I right in doing this(passing pointer instead of making the data
structure static) ?

Yes. Or maybe No. We don't know enough about the
constraints and circumstances of your situation to be able
to say with certainty.

2. Is there any alternative to this ?

You might consider a sort of intermediate strategy: Make
the pointer(s) global and static, and initialize them to
point to dynamically-zeroed memory when the program starts.
That is, if the program as it stands now has

int BigArray[LARGE]; /* static and zeroed */

you might change it to

int *BigArray; /* only the pointer is static */
...
void initialize(void) {
BigArray = calloc(LARGE, sizeof *BigArray);
if (BigArray == NULL)
die_horribly();
}

.... and arrange to call initialize() before BigArray is needed
elsewhere in the code.

--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxx

.



Relevant Pages

  • 4 Ways how to communicate between programs
    ... Pass al parameters together through a data structure or a file. ... In this case You may initialize just those parameters ... The best way is calling via CMD interface. ... RPG is currently not supporting it. ...
    (comp.sys.ibm.as400.misc)
  • Re: what is the initial value of arrays of object
    ... scenario where it's possible to imagine that the technique might ... Presumably, in such an interface, the program maintains a data structure that tracks those controls and that data structure easily could be an array initialized in the manner discussed here. ... there's absolutely no reason to think that a person might not ever legitimately initialize such an array in a real-world program. ... Even if no person participating in this newsgroup has ever personally written software that uses that type of initialization, that's not in any way proof of uselessness of the technique. ...
    (comp.lang.java.programmer)
  • Re: How do I delete a folder through code?
    ... The last time I looked at this, which was a looooooong time ago, ... SOP is to never explicitly initialize static duration data to zero. ... This is an idiomatic way to initialize a data structure whose first member ...
    (microsoft.public.vc.mfc)