All pastes #792207 Raw Edit

k4st

public c v1 · immutable
·published 2007-11-21 06:37 UTC
rendered paste body
/* Read a word from the file in as a tree item. */TreeItem *readTreeItem(FILE * infile) {	char *word;	TreeItem *item;		/* we scan one word at a time */	if(!feof(infile) && fscanf(infile, "%s", word) != EOF) {				/* allocate the tree item */		if((item = XMALLOC(TreeItem *, sizeof(TreeItem))) == NULL) {			ERROR_XMALLOC("Could not allocate enough memory for 'item'.");		}				/* dynamically allocate the word in the tree item */		if((item->word = XMALLOC(char *, sizeof(char) * (strlen(word)+1))) == NULL) {			ERROR_XMALLOC("Could not allocate enough memory for 'item->word'.");		}				*item->word = *word;				return item;	}	return NULL;}