Hello List
Well... this question come in handy. If I have, say, one n dimension
array who points to some struct who, on his initialization time,
points to another struct, like (Just a sample):
typedef struct
{
char ****args;
int **index_args;
} arguments;
typedef struct
{
char ***values;
int *index_values;
} what;
struct
{
what ***ever;
/* ok... I have other stuff in here, but the main question point
is illustrated */
} mystruct;
What should be the best practice on memory allocation? All in one time
or each element, one by one?
To know better what a hell is all that about, I have x elements(char
***values). Each value should receive n arguments (before runtime, and
even on runtime - since some values should change from network input -
I don't know the number of arguments for each value. All must be
dynamic).
Lets say I have:
value[0][index_values[0]]="%s %s %s.\n";
On args, I need:
args[0][index_values[0]][index_args[0][0]]="The";
args[0][index_values[0]][index_args[0][1]]="final";
args[0][index_values[0]][index_args[0][2]]="string";
I'm trying to make this sample very very simple, but this can create a
problem. The application looks too weird to work out this simple task.
In the main context (is not here), this way make more sense (at least
to me, so far
.
To:
int myvprintf(const char *format, ...)
{
int rv=0;
va_list arguments_list;
va_start(arguments_list,format);
rv=vprintf(format,arguments_list); /* vprintf here, but I'm using
vsprintf in the real code */
va_end(arguments_list);
if(rv<0)
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
Thanks
Rafael