Name: Anonymous 2010-11-26 14:39
ENTERPRISE C
could one of you experts optimize this even further?
typedef struct{
int *bars;
int n;
}foo;
int addBarToFoo(foo *f,int k)
{
int i;
foo *old = f;
if(!(f = calloc(f->n+1,sizeof(foo))))
return FALSE;
for(i=0;i<f->n;++i)
f->bars[i] = old[i];
f->bars[f->n] = k;
free(old);
return TRUE;
}could one of you experts optimize this even further?