I
istillshine
double *foo(double *x, int *ret)
{
double *x;
int sz;
x = malloc(100);
/* do something on x */
/* compute sz */
ret = malloc(sz);
/* do something on y*/
return x;
}
In foo, sz's value is computed during running. My question is how to
return
x and ret in the same time, without using a structure like the
following?
struct ret_val_t {
double *x;
int *ret;
}
One solution might be to use a global variable, int *ret. But I think
this is not a good solution since people usually recommend agaist
using global variables.
{
double *x;
int sz;
x = malloc(100);
/* do something on x */
/* compute sz */
ret = malloc(sz);
/* do something on y*/
return x;
}
In foo, sz's value is computed during running. My question is how to
return
x and ret in the same time, without using a structure like the
following?
struct ret_val_t {
double *x;
int *ret;
}
One solution might be to use a global variable, int *ret. But I think
this is not a good solution since people usually recommend agaist
using global variables.