Path: utzoo!attcan!uunet!samsung!umich!yale!quasi-eli!cs.yale.edu!tarr-michael From: tarr-michael@CS.YALE.EDU (michael tarr) Newsgroups: comp.sys.mac.programmer Subject: Help with bad calloc() call in THINK C 4.02 Message-ID: <26250@cs.yale.edu> Date: 19 Sep 90 16:14:05 GMT Sender: news@cs.yale.edu Organization: Department of Psychology, Yale University Lines: 74 Nntp-Posting-Host: algeria.ai.cs.yale.edu For some reason using THINK C 4.02 the following calloc (at the end of the code segment) breaks. It returns a pointer that is not really valid (but not NULL). Here are the data structures used: struct objects { short theObj; Rect theRect; RGBColor theColor; Point thePen; struct objects *next_object; }; typedef struct objects objects; struct picts { char* thePict; struct picts *next_pict; }; typedef struct picts picts; struct symbolList { char* theSym; objects *symObj; picts *symPict; struct symbolList *next_symbol; }; typedef struct symbolList symbolList; symbolList *symbols; objects *objPtr; picts *pictPtr; symbolList *symPtr; /*** OpenSymbolFile ***/ extern void OpenSymbolFile(char*); void OpenSymbolFile(char* symFile) { FILE* symfp; char inStr[80], tempStr[30]; char graphOp[15]; RGBColor penColor = { 0x0000, 0x0000, 0x0000 }; Point penDim = { 1 ); FatalError(); } symbols = 0; while ( fscanf(symfp, "%s", inStr) != EOF ) { if (symbols == 0) { if ( !ValidPointer( (Ptr) (symbols = (symbolList*) calloc( (size_t) 1, (size_t) sizeof(symbolList) )) ) ) { /*^^^^^^ bad calloc -- any ideas? */ ErrorHandler( "OpenSymbolFile", "Failed calloc for symbolList at:", inStr, FATAL_ALERT ); FatalError(); } symbols->next_symbol = 0; symPtr = symbols; } Any ideas? Mike Tarr tarr@cs.yale.edu -- * Mike Tarr The Human Neuron Project * * tarr@cs.yale.edu Department of Psychology * * "My opinions are always my own." Yale University * **************************************************************************