All pastes #953801 Raw Edit

Stuff

public text v1 · immutable
#953801 ·published 2008-03-23 11:11 UTC
rendered paste body
int llistAdd(LList list, char const *text) {
	//LListNode *first = (LListNode *)malloc(sizeof(LListNode));
	LListNode *new = (LListNode *)malloc(sizeof(LListNode));
	LListNode *prev = (LListNode *)malloc(sizeof(LListNode));
	if  (new == NULL)
		return 0;
	new->text = (char *)malloc(sizeof(char)*(strlen(text)+1));
	strcpy(new->text, text);
	new->next = NULL;
	if (list->first == NULL)
		list->first = new;
	else {
		for (prev = list->first; prev != NULL; prev = prev->next) {
			prev->next = new;
		}
	}
	return 1;	
}