F
fl
Hi,
The following part of routine is originally run on a Linux OS. It
works. Now, I want to run it on Microsoft MSC Express 8.0 on a Windows
XP. I find that the heap corrupt at the second time call
distrib_create (before the free function).
Do you have some ideas on how to solve this easily? Thanks.
..................
distrib *distrib_create
( char *c /* String describing distribution over numbers */
)
{
distrib *d;
char *str, *tstr;
int i, n, scan_num, size;
double prop, sum;
double d_tmp;
char junk;
/* Check for special case of a single number. */
if (sscanf(c,"%d%c",&n,&junk)==1 && n>0)
{ tstr = chk_alloc ( (int)(2.1+log10(n)), sizeof(*str));
sprintf(tstr,"1x%d",n);
d = distrib_create(tstr);
free(tstr);
return d;
}
....
....
The following part of routine is originally run on a Linux OS. It
works. Now, I want to run it on Microsoft MSC Express 8.0 on a Windows
XP. I find that the heap corrupt at the second time call
distrib_create (before the free function).
Do you have some ideas on how to solve this easily? Thanks.
..................
distrib *distrib_create
( char *c /* String describing distribution over numbers */
)
{
distrib *d;
char *str, *tstr;
int i, n, scan_num, size;
double prop, sum;
double d_tmp;
char junk;
/* Check for special case of a single number. */
if (sscanf(c,"%d%c",&n,&junk)==1 && n>0)
{ tstr = chk_alloc ( (int)(2.1+log10(n)), sizeof(*str));
sprintf(tstr,"1x%d",n);
d = distrib_create(tstr);
free(tstr);
return d;
}
....
....