engine/EngineConsole.c
/*	Tablist is a doubly-linked loop, alphabetized by name
*/
Tablist is a doubly-linked loop, alphabetized by name
Tablist is a doubly - linked loop alphabetized by name
void AddToTabList (const char *name, char *type)
{
	tab_t	*t,*insert;
	t = (tab_t*)Hunk_Alloc(sizeof(tab_t));
	strncpy(t->name, name, sizeof(t->name));
	t->type = type;
	if (!tablist) 
	{
		tablist = t;
		t->next = t;
		t->prev = t;
	}
	else if (strcmp(name, tablist->name) < 0) 
	{
		t->next = tablist;
		t->prev = tablist->prev;
		t->next->prev = t;
		t->prev->next = t;
		tablist = t;
	}
	else 
	{
		insert = tablist;
		do
		{
			if (strcmp(name, insert->name) < 0)
				break;
			insert = insert->next;
		} while (insert != tablist);
		t->next = insert;
		t->prev = insert->prev;
		t->next->prev = t;
		t->prev->next = t;
	}
}
void AddToTabList ( const char * name , char * type ) { tab_t * t , * insert ; t = ( tab_t * ) Hunk_Alloc ( sizeof ( tab_t ) ) ; strncpy ( t -> name , name , sizeof ( t -> name ) ) ; t -> type = type ; if ( ! tablist ) { tablist = t ; t -> next = t ; t -> prev = t ; } else if ( strcmp ( name , tablist -> name ) < 0 ) { t -> next = tablist ; t -> prev = tablist -> prev ; t -> next -> prev = t ; t -> prev -> next = t ; tablist = t ; } else { insert = tablist ; do { if ( strcmp ( name , insert -> name ) < 0 ) break ; insert = insert -> next ; } while ( insert != tablist ) ; t -> next = insert ; t -> prev = insert -> prev ; t -> next -> prev = t ; t -> prev -> next = t ; } }
Tablist is a doubly-linked loop, alphabetized by name
Tablist is a doubly - linked loop alphabetized by name
//create list //insert at front //insert later