u_object u_pair_create(u_object car, u_object cdr) { gc_push(car); gc_push(cdr); // all the pair created through gc module?? u_pair *pair = gc_alloc_hobject(); pair->type = U_PAIR; pair->val.pair.car = car; pair->val.pair.cdr = cdr; gc_pop(); // why pop ? what if no push, no pop? gc_pop(); return u_pair_to_obj(pair); // also the key point }
void omove_ast_up_full(oast_t *ast, oast_t *move) { assert(move == ast->l.ast || move == ast->r.ast || move == ast->t.ast || move == ast->c.ast); gc_push(move); ast->l.ast = move->l.ast; ast->r.ast = move->r.ast; ast->t.ast = move->t.ast; ast->c.ast = move->c.ast; ast->token = move->token; move->l.value = move->r.value = move->t.value = move->c.value = null; odel_object((oobject_t *)&move); gc_dec(); }
void deleteNode(game_obj* node) { /* * A <-> B <-> C * A <-> C */ game_obj* prev = node->prev; game_obj* next = node->next; if(prev != NULL) if(prev->next != NULL) prev->next = next; if(next != NULL) if(next->prev != NULL) next->prev = prev; gc_push(node); }
sexp_t *prim_append(sexp_t *args) { sexp_t *lst, *ret; if (list_len(args) == 0) return nil; if (isnil(car(args))) return prim_append(cdr(args)); if (isnil(cdr(args))) return copy_list(car(args)); if (!iscons(car(args)) || list_len(car(args)) < 0) { fprintf(stderr, "error: proper list expected\n"); return NULL; } for (ret = lst = copy_list(car(args)); cdr(lst) != nil; lst = cdr(lst)) ; gc_push(&ret); lst->data = make_cons(car(lst), prim_append(cdr(args))); gc_pop(); return ret; }
static dl_code_e pop_render(void * pcom, dl_context_t * context) { return !gc_push(((struct gc_com *)pcom)->flags) ? DL_COMMAND_OK : DL_COMMAND_ERROR; }