Re: malloc and memcpy
On Thu, 05 Jul 2007 07:29:15 -0700, a7zulu@gmail.com wrote:
typedef struct FPARRAY{
unsigned short iRows,
iCols;
double dArray[FPARRAY_SIZE];
} FPARRAY;
__declspec(dllexport) double initialize(LPFP st, LPFP h, LPFP ffd,
LPFP bt, int hr, int it, int ic)
{
swap_table = (LPFP)malloc(sizeof(FPARRAY));
You should always check the return from malloc for success. An 800
element array of double should not be a problem but we have no idea
what else you are doing.
memcpy(swap_table, st, sizeof(FPARRAY));
Are you sure that all the input arguments (e.g., st) have valid
non-NULL values?
holidays = (LPFP)malloc(sizeof(FPARRAY));
memcpy(holidays, h, sizeof(FPARRAY));
futurefrontdate = (LPFP)malloc(sizeof(FPARRAY));
memcpy(futurefrontdate, ffd, sizeof(FPARRAY));
blend_table = (LPFP)malloc(sizeof(FPARRAY));
memcpy(blend_table, bt, sizeof(FPARRAY));
holiday_rule = hr;
int_tech = it;
int_curve = ic;
}
so essentially i wrote a dll, and I can get excel to pass to me these
things called FPARRAY structures. I comment a few of the malloc and
memcpy and the function is able to run a few times before crashing. i
am not exactly sure whats going
This certainly sounds like a space limitation issue. You are invoking
the DLL from Excel? Does Excel impose some constraint on the amount
of memory available for dynamic allocation?
Remove del for email