Skip to content

Instantly share code, notes, and snippets.

@isag
Created March 31, 2012 08:44
Show Gist options
  • Save isag/2260967 to your computer and use it in GitHub Desktop.
Save isag/2260967 to your computer and use it in GitHub Desktop.
double *tr_sp_array(ParamSP *p0)
{
ParamSP *p = (ParamSP*)malloc(sizeof(ParamSP));
memcpy((void*)p,(void*)p0,sizeof(ParamSP));
double *param_sp = (double*)malloc(6*sizeof(double));
param_sp[0] = (double)p->cycle_num;
param_sp[1] = (double)p->number;
param_sp[2] = (double)p->ab;
param_sp[3] = (double)p->pc;
param_sp[4] = p->input;
param_sp[5] = p->mass;
free(p);
return param_sp;
}
@PhDP
Copy link

PhDP commented Mar 31, 2012

I don't like this code for a couple of reasons, you could avoid both malloc. I'll fork it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment