Ben Simons (ben++at++vislab.su.edu.au)
Mon, 15 May 1995 13:55:13 -0400
I am having trouble using the Structure Browser on structures
that have been created via pfMalloc. In particular, I can't
dereference the pointer returned; I get the error:
``variable <blah> is used before it is set''
and, yes, I am double clicking the address in the structure node
of the structure browser after the pfMalloc() returns. Variable
<blah> is set to NULL before the call to pfmalloc, so I know that
the allocation does return an address.
Any ideas??
ben.
------
To make the question explicit, Here's some example code...
typedef struct pressureHeader {
int howmany;
int whichSet;
int xsize;
int ysize;
PressChart *chartHead;
PressChart *chartTail;
} pressureHeader;
pressureHeader *
createPressHeader( void)
{
void *arena = pfGetSharedArena();
pressureHeader *pressHeader;
int structSize;
if( arena == NULL) {
fprintf( stderr, "Error: createPressHeader(): ");
fprintf( stderr, "can't get ptr to arena!\n");
return( NULL);
}
structSize = sizeof( pressureHeader);
pressHeader = (pressureHeader *)pfMalloc( structSize, arena);
if( pressHeader == NULL) {
fprintf( stderr, "Error: createPressHeader(): ");
fprintf( stderr, "can't malloc pressureHeader\n");
return( NULL);
}
return( pressHeader);
}
main()
{
pressureHeader *ph = NULL;
fprintf(stderr, "starting.\n");
pfInit();
ph = createPressHeader();
ph->howmany = 9;
ph->whichSet = 2;
ph->chartTail = NULL;
fprintf(stderr, "done.\n");
}
When execution gets to the line with "ph->whichSet" in it, I expect
that I should be able to use the Struct Browser to see ph. This is
when I get the error: ph is used before it is set.
The versions I am running are: IRIX 5.3, performer 1.2, and (cvd) Workshop 2.4
Nb. if I add a variable:
pressureHeader ph2;
to main(), then I can browse ph2.
-- _______________________________________________________ Ben Simons Physics Building, A28, VisLab Systems Manager Sydney University. NSW. Phone +61-2-351-3005 AUSTRALIA. 2006.
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:29 PDT