I hope that you are using GCC, otherwise my advice will not work.
I will give a piece of code
typedef struct XXX_ELEMENT_tag
{
UINT8 num;
UINT8 param;
UINT16 fre1;
INT16 a1;} ;
typedef struct XXX_ELEMENT_tag ELEMENT_T;
typedef struct XYZ_S_tag {
UINT8 num_elements;
UINT8 flag;
ELEMENT_T * element; /*** Array should be dynamically
allocated, not a static ***/
} XYZ_S_tag;
typedef struct T_TABLE_tag
{
XYZ_S_tag run;
XYZ_S_tag walk;
.... /* alot of these */
XYZ_S_tag crawl;} TABLE_T;
typedef struct T_TABLE_tag T_table;
T_table t_table =3D
{
{ /* In GCC you may initialise elements in random order. You
should use GCC extension
http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html=
#SEC81
*/
2, /* Num Elements */
APPLY_WINDOW, /* Flag */
(ELEMENT_T[]){
/* N p f a */
/* 0 */ { 2, 0, 480, -240 },
/* 1 */ { 0, 0, 0, 500 },
}
},
{ /* walk */
/* repeat many many times */
}
}
}
Hope that will help.
On 17 =C6=C5=D7, 21:04, Chris LaVelle <cjlave...@[EMAIL PROTECTED]
> wrote:
> I don't know the easiest way to explain this so, I'm going to give an
> example of how it is today....and what I'm trying to accomplish.
>
> in the header...
> typedef struct XXX_ELEMENT_tag
> {
> =9A =9AUINT8 =9A num;
> =9A =9AUINT8 =9A param;
> =9A =9AUINT16 =9Afre1;
> =9A =9AINT16 =9A a1;} ;
>
> typedef struct XXX_ELEMENT_tag ELEMENT_T;
>
> #define MAX_ELEMENTS 8
> typedef struct XYZ_S_tag {
> =9A =9A UINT8 =9A =9A num_elements;
> =9A =9A UINT8 =9A =9A flag;
> =9A =9A ELEMENT_T element[MAX_E]; =9A =9A/*** This is the spot ***/
>
> } XYZ_S_tag;
>
> And of course the S_tag structure is buried one more structure down.
> Say something like:
>
> typedef struct T_TABLE_tag
> {
> =9A =9AXYZ_S_tag run;
> =9A =9AXYZ_S_tag walk;
> =9A =9A.... =9A/* alot of these */
> =9A =9AXYZ_S_tag crawl;} TABLE_T;
>
> typedef struct T_TABLE_tag T_table;
>
> And in a C file a global is initialized like this...
> T_table t_table =3D
> {
> =9A =9A =9A =9A { /* run =9A =9A =9A*/
> =9A =9A =9A =9A =9A =9A =9A =9A 2, /* Num Elements */
> =9A =9A =9A =9A =9A =9A =9A =9A APPLY_WINDOW, /* Flag */
> =9A =9A =9A =9A =9A =9A =9A =9A {
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* =9A =9A =9A =9AN =9Ap
=
=9A f =9A =9A a */
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* 0 */ { 2, 0, 480,
-240 =
},
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* 1 */ { 0, 0, =9A 0,
500=
},
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* 2 */ { 0, 0, =9A 0, 0
}=
,
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* 3 */ { 0, 0, =9A 0, 0
}=
, =9A =9A =9A
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* 4 */ { 0, 0, =9A 0, 0
}=
,
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* 5 */ { 0, 0, =9A 0, 0
}=
,
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* 6 */ { 0, 0, =9A 0, 0
}=
,
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* 7 */ { 0, 0, =9A 0, 0
}=
,
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* 8 */ { 0, 0, =9A 0, 0
}=
,
> =9A =9A =9A =9A =9A =9A =9A =9A }
> =9A =9A =9A =9A },
> =9A =9A =9A =9A { /* walk =9A*/
> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A /* repeat many many
times =
*/
> =9A =9A =9A =9A =9A =9A =9A =9A }
> =9A =9A =9A =9A }
>
> }
>
> Ok, let's just say element is bigger than my example above and there are
> about a 1000 of these, only half of which have data. =9AI've inherited
> this code and this table is occupying 300k of memory and memory's tight.
> I want to delete all the filler rows and declare element in a way that
> the compiler will auto size what it needs for each instance. =9AI have
the=
> number of elements. =9AI would have thought something along the lines of
> *element instead of element[MAX_E]. =9ABut I get warnings about the
> unexpected brace for element. =9AIs there a way to make the compiler
auto
> size the space for me? =9AIn the above example I would be deleting rows
2-=
8.
>
> Any and all help is appreciated?
>
> Thanks
> cj
> --
> comp.lang.c.moderated - moderation address: c...@[EMAIL PROTECTED]
-- you
must
> have an appropriate newsgroups line in your header for your mail to be
see=
n,
> or the newsgroup name in square brackets in the subject line. =9ASorry.
--
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
-- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.


|