Hi Bruce
class.c line 1437: added comments which are questions below:
I'm trying to reorganise code, but need to understand fully first.
....
//found same class, but some part of class changed
//so
pcl = realloc(pcl,
sizeof(CLASS)+strlen(szargs[1])+1+
strlen(szScriptPath)+1+strlen(szName)+1+lenVars+lenFunc+1);
if (!pcl)
{
g_ppsv->ErrMessage("No memory for new class: ",szargs[1]);
//no return here? Ins;t that storing up trouble for what follows?
}
}
}
if (!pcl)
// could be either class name not found, or failed realloc above
{
if (g_iNumClass>=g_iSizeClass)
{
g_iSizeClass+=g_iIncrClass;
g_cl=(CLASS**)realloc(g_cl, sizeof(CLASS*)*g_iSizeClass);
if (!g_cl)
{
g_ppsv->ErrMessage("No memory for class table:",szargs[1]);
return;
}
}
//overall length here is one less that realloc above? Reason?
pcl = CLASS*)malloc(sizeof(CLASS)+strlen(szargs[1])+1+
strlen(szScriptPath)+strlen(szName)+1+lenVars+lenFunc+1);
if (!pcl)
{
g_ppsv->ErrMessage("No memory for new class: ",szargs[1]);
return;
}
iClass=g_iNumClass++; //...in which case new class defined
pcl->nObjects=0; // orphan all objects based on class
}
//if malloc succeeds here realloc above failed, you're trying to
//redefine the class, but have to assign a new handle, so all
//objects derived from old class orphaned??