S
Schizoid Man
Hi,
I have a function in which I am reading in an integer value, and
dynamically creating an array of type double and size of the integer value:
double compute(int steps, int typeopt)
{
double *price_array;
price_array = (double *) malloc(sizeof(int) * steps);
...
}
So far so good.
Now in my main method, I invoke this function twice:
value = compute(steps, 0);
printf("\n%5.5lf", value);
value = compute(steps, 1);
printf("\n%5.5lf", value);
I get a correct answer for the first time it is invoked, but I get the
following error when the function is invoked the second time (i.e
typeopt = 1): Unhandled exception at 0x00411816: 0xC0000005: Access
violation writing location 0x00000000.
I then go back to the compute method and put a free(price_array);
statement at the end of the method.
I then get the following message:
HEAP: Heap block at 00355870 modified at 0035606C past requested size of
7f4 Windows has triggered a breakpoint. This may be due to a corruption
of the heap, and indicates a bug in or any of the DLLs it has loaded.
The output window may have more diagnostic information.
I would really appreciate any help at all.
Thanks in advance,
Schiz
I have a function in which I am reading in an integer value, and
dynamically creating an array of type double and size of the integer value:
double compute(int steps, int typeopt)
{
double *price_array;
price_array = (double *) malloc(sizeof(int) * steps);
...
}
So far so good.
Now in my main method, I invoke this function twice:
value = compute(steps, 0);
printf("\n%5.5lf", value);
value = compute(steps, 1);
printf("\n%5.5lf", value);
I get a correct answer for the first time it is invoked, but I get the
following error when the function is invoked the second time (i.e
typeopt = 1): Unhandled exception at 0x00411816: 0xC0000005: Access
violation writing location 0x00000000.
I then go back to the compute method and put a free(price_array);
statement at the end of the method.
I then get the following message:
HEAP: Heap block at 00355870 modified at 0035606C past requested size of
7f4 Windows has triggered a breakpoint. This may be due to a corruption
of the heap, and indicates a bug in or any of the DLLs it has loaded.
The output window may have more diagnostic information.
I would really appreciate any help at all.
Thanks in advance,
Schiz