static void push_str(CParseInfo *pCPI, enum CTErrorSeverity severity, void *str) { if (pCPI == NULL || pCPI->errorStack == NULL) F.fatalerr(str); LL_push(pCPI->errorStack, error_new(severity, str)); }
void LL_add(LL_node **head_result, LL_node **tail_result, LL_node *num1, LL_node *num2) { LL_node *node1, *node2; int sum, remainder, carry; *head_result = *tail_result = NULL; node1 = num1; node2 = num2; carry = 0; while (num1) { sum = (int) (num1->value + num2->value) + carry; remainder = (sum % 10); carry = (sum / 10); if (*head_result == NULL) LL_init(head_result, tail_result, (double) remainder); else LL_push(tail_result, (double) remainder); num1 = num1->next; num2 = num2->next; }; };
void PushErrorHandler(ErrorHandler handler) { if(!ErrorHandlerStack) ErrorHandlerStack=LL_create(); LL_push(ErrorHandlerStack,(void *)handler); return; }
void PostOrder(BTNode *node) { LinkedList list = LL_init(); BTNode *tmp; while (node != NULL || !LL_isEmpty(list)) { if (node != NULL) { LL_push(list, node); node = node->left; } else { tmp = (BTNode *)LL_pop(list); if (tmp->first == 0) { // first time tmp->first = 1; LL_push(list, tmp); node = tmp->right; } else { H_DEBUG_MSG("%s", tmp->data); node = NULL; } } } }
void PreOrder(BTNode *node) { LinkedList list = LL_init(); while (node != NULL || !LL_isEmpty(list)) { if (node != NULL) { H_DEBUG_MSG("%s", node->data); LL_push(list, node); node = node->left; } else { node = ((BTNode *)LL_pop(list))->right; } } }
static void get_names_callback(const CMacroInfo *pmi) { struct get_names_cb_arg *a = pmi->arg; if (a->ll) { dTHXa(a->interp); LL_push(a->ll, newSVpv(pmi->name, 0)); } else { a->count++; } }
int main(int argc, char **argv) { LL_node *head1, *head2, *tail1, *tail2, *head_res, *tail_res; LL_init(&head1, &tail1, 3.0); LL_push(&tail1, 1.0); LL_push(&tail1, 5.0); LL_init(&head2, &tail2, 5.0); LL_push(&tail2, 9.0); LL_push(&tail2, 2.0); LL_add(&head_res, &tail_res, head1, head2); printf("Number 1:\n"); LL_print(head1); printf("Number 2:\n"); LL_print(head2); printf("Answer:\n"); LL_add(&head_res, &tail_res, head1, head2); LL_print(head_res); };
void handle_string_list(pTHX_ const char *option, LinkedList list, SV *sv, SV **rval) { const char *str; if (sv) { LL_flush(list, (LLDestroyFunc) string_delete); if (SvROK(sv)) { sv = SvRV(sv); if (SvTYPE(sv) == SVt_PVAV) { AV *av = (AV *) sv; SV **pSV; int i, max = av_len(av); for (i = 0; i <= max; i++) { if ((pSV = av_fetch(av, i, 0)) != NULL) { SvGETMAGIC(*pSV); LL_push(list, string_new_fromSV(aTHX_ *pSV)); } else fatal("NULL returned by av_fetch() in handle_string_list()"); } } else Perl_croak(aTHX_ "%s wants an array reference", option); } else Perl_croak(aTHX_ "%s wants a reference to an array of strings", option); } if (rval) { ListIterator li; AV *av = newAV(); LL_foreach(str, li, list) av_push(av, newSVpv(CONST_CHAR(str), 0)); *rval = newRV_noinc((SV *) av); } }
void PushError(Error * topush) { LinkedListEnum * llenum; ErrorHandler curhandler; if(!ErrorStack) ErrorStack=LL_create(); LL_push(ErrorStack,(void *)topush); if(ErrorHandlerStack) { llenum=LL_newenum(ErrorHandlerStack); curhandler=(ErrorHandler)LL_end(llenum); while(curhandler) { curhandler(); curhandler=(ErrorHandler)LL_previous(llenum); } LL_enumdelete(llenum); } return; }
void Tr_genLoopDoneLabel(){ //Put a new label into the label list Temp_label f = Temp_newlabel(); LL_push(f); debug("new loop done label generated"); }
static void disabled_keywords(pTHX_ LinkedList *current, SV *sv, SV **rval, u_32 *pKeywordMask) { const char *str; LinkedList keyword_list = NULL; if (sv) { if (SvROK(sv)) { sv = SvRV(sv); if (SvTYPE(sv) == SVt_PVAV) { AV *av = (AV *) sv; SV **pSV; int i, max = av_len(av); u_32 keywords = HAS_ALL_KEYWORDS; keyword_list = LL_new(); for (i = 0; i <= max; i++) { if ((pSV = av_fetch(av, i, 0)) != NULL) { SvGETMAGIC(*pSV); str = SvPV_nolen(*pSV); #include "token/t_keywords.c" success: LL_push(keyword_list, string_new(str)); } else fatal("NULL returned by av_fetch() in disabled_keywords()"); } if (pKeywordMask != NULL) *pKeywordMask = keywords; if (current != NULL) { LL_destroy(*current, (LLDestroyFunc) string_delete); *current = keyword_list; } } else Perl_croak(aTHX_ "DisabledKeywords wants an array reference"); } else Perl_croak(aTHX_ "DisabledKeywords wants a reference to " "an array of strings"); } if (rval) { ListIterator li; AV *av = newAV(); LL_foreach (str, li, *current) av_push(av, newSVpv(CONST_CHAR(str), 0)); *rval = newRV_noinc((SV *) av); } return; unknown: LL_destroy(keyword_list, (LLDestroyFunc) string_delete); Perl_croak(aTHX_ "Cannot disable unknown keyword '%s'", str); }
static void get_defs_callback(const CMacroInfo *pmi) { struct get_defs_cb_arg *a = pmi->arg; dTHXa(a->interp); LL_push(a->ll, newSVpv(pmi->definition, pmi->definition_len)); }