OK, this one’s truly a stumper for me.
I’m still trying to load configuration from an external file (not Notes.ini) using the C API Toolkit. Moving to the C++ API toolkit is a non-starter (it’s not available to me), and using Notes.ini would involve a requirements change, so that’s not a real option either.
Here’s a dummy code fragment that should demonstrate the problem:
==================================
struct Foo {
int num;
char *str;
};
/* This is a registered extension manager call */
EMHandlerProc(…)
{
struct Foo *tempBoom = NULL;
/* handler proc init stuff */
if ( allocateFoo(&tempBoom) )
{
printf("tempBoom.num = %d\n", tempBoom->num); /* Shows garbage */
printf("tempBoom.str = %s\n", tempBoom->str); /* Goes BOOM! */
}
/* rest of the handler proc */
}
BOOL allocateFoo(struct Foo **outFoo)
{
if ( outFoo != NULL )
{
struct Foo *temp = NULL;
temp = (struct Foo*)calloc(1, sizeof(struct Foo));
if ( temp != NULL )
{
temp->num = "1776";
temp->str = (char*)calloc(20, sizeof(char));
if ( temp->str != NULL )
{
strncpy(temp->str, "July 4th", strlen("July 4th"));
if ( *outFoo != NULL )
{
/* destroy old info */
}
*outFoo = temp;
temp = NULL;
printf("outFoo = %s, %d\n",(*outFoo)->str, (*outFoo)->num); /* prints correct values */
return TRUE;
}
else
{
/* destroy temp */
return FALSE;
}
}
else
{
return FALSE;
}
}
else
{
return FALSE;
}
}
======================================
I’ve tried using global variables, fixed-length variables, pure stack variables, the various OSMemory*() functions; none of them seem to help. Within the function (allocateFoo()) everything is golden. As soon as I exit the function, everything goes belly up.
Sound familiar? Any fixes?