int BTInsert(symbolTablePtr *root, char *key, symbol s){ if (*root == NULL){ symbolTablePtr tmp; if ((tmp = gMalloc(sizeof(struct BTree))) == NULL){ return BT_ERR; } tmp->key = key; tmp->content = s; tmp->LPtr = NULL; tmp->RPtr = NULL; *root = tmp; return BT_OK; } else{ int cmp = strcmp((*root)->key, key); if (cmp < 0){ return BTInsert(&(*root)->LPtr, key, s); } if (cmp > 0){ return BTInsert(&(*root)->RPtr, key, s); } if (cmp == 0){ return BT_ERR; // vratim error, protoze polozka j*z v tabulce je } } return BT_OK; }
void instListInsert(tInstList *list, tInst inst){ // vklada prvek a konec seznamu tItem *tmp; if ((tmp = gMalloc(sizeof(struct Item))) == NULL){ result = INT_ERR; return; } tmp->instruction = inst; tmp->ptr = NULL; if (list->First == NULL){ list->First = tmp; } else{ list->Last->ptr = tmp; } list->Last = tmp; }