Ok, when I used that code I got an odd error:
request for member `sections'' in something not a structure or union.
So I changed ManifestSection to:
void ManifestSection(struct Section **s, unsigned int x, unsigned int y)
{
struct Section *temp=(struct Section *)malloc(sizeof(struct Section));
temp->grid=(unsigned long int **)malloc(PTRSIZE*10000);
temp->x=x;
temp->y=y;
*s=temp;
}
all things seem to be working without seg faults, but is there a better way to do this without a temporary variable. My attempts at typecasting seemed to fail. Thanks in advance.
Pointer Hell
This avoids the temporary variable,
void ManifestSection( struct Section **s, unsigned int x, unsigned int y ){ assert( s ); *s = (struct Section*) malloc( sizeof(**s) ); (*s)->grid = (unsigned long int**) malloc( PTRSIZE * 10000 ); (*s)->x = x; (*s)->y = y;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement