H
hotadvice
hi there
i think this is an off topic question
but i think u folks ,,,here know the best....
so ....
case 1)
say i have 5 global variables.
int g_var1,g_var2,g_var3,g_var4,g_var5;
this will increase the data segment size needed by my program by 20
bytes (assuming sizeof(int) is 4 bytes).
case 2)
now if i do this
struct global_info {
int g_var1;
int g_var2;
int g_var3;
int g_var4;
int g_var5;
};
struct global_info* g_info = (struct global_info* )
malloc( sizeof(struct global_info) );
and later i can free the malloced memory.
so, i guess in case 2 , i will have more code size but manageable data
size
and in case 1 .. i will have less code size.. but my data uasage will
always be atleast 20 bytes.
/////////////////////
as an after thought...in case 2 .... my increased code will always be
in memory....
well....what u guys will prefer...
offcourse i am in a very resource constrained environemnt and we are
always
told to reduce data size as much as possible..
do those folks mean code size too...
i think this is an off topic question
but i think u folks ,,,here know the best....
so ....
case 1)
say i have 5 global variables.
int g_var1,g_var2,g_var3,g_var4,g_var5;
this will increase the data segment size needed by my program by 20
bytes (assuming sizeof(int) is 4 bytes).
case 2)
now if i do this
struct global_info {
int g_var1;
int g_var2;
int g_var3;
int g_var4;
int g_var5;
};
struct global_info* g_info = (struct global_info* )
malloc( sizeof(struct global_info) );
and later i can free the malloced memory.
so, i guess in case 2 , i will have more code size but manageable data
size
and in case 1 .. i will have less code size.. but my data uasage will
always be atleast 20 bytes.
/////////////////////
as an after thought...in case 2 .... my increased code will always be
in memory....
well....what u guys will prefer...
offcourse i am in a very resource constrained environemnt and we are
always
told to reduce data size as much as possible..
do those folks mean code size too...