/* * Deletes every direction queue and exits the program. */ void cleanexit() { q_delete('n'); q_delete('s'); q_delete('e'); q_delete('w'); q_shutdown; exit(EXIT_FAILURE); }
void root_thread_exit (void) { t_delete(producer_tid); t_delete(consumer_tid); q_delete(message_qid); }
void free_oplist (void) { if (oplist == NULL) return; int i = 0; for(i=0; i<__TABLE_SIZE; ++i) { while(!q_empty(&oplist[i])) { struct q_elem *e = q_delete(&oplist[i]); struct op_elem *oe = q_entry(e, struct op_elem, elem); if (oe->opcode != NULL) free(oe->opcode); free(oe); } } free (oplist); oplist = NULL; if (optype != NULL) { free (optype); optype = NULL; } }
int main() { struct queue q; int data; q_init(&q); while (1) { printf("Enter\n\t1: Insert\n\t2: Delete\n\t3: Exit\n\t: "); scanf("%d", &data); switch (data) { case (1): printf("\nEnter Number: "); scanf("%d", &data); q_insert(&q, data); printf("Done\n"); break; case (2): data = q_delete(&q); printf("\nData = %d\n", data); break; default: exit(1); break; } } return 0; }
// removes all trailing whitespaces struct queue * save_file (const char *filename) { if (!is_file(filename)) return NULL; struct queue *q = malloc (sizeof (struct queue)); if (q == NULL) return NULL; q_init (q); FILE *fp = fopen(filename, "r"); char buf[128]; int i; while (fgets(buf, 128, fp) != NULL) { // cut all trailing whitespace for (i=strlen(buf) - 1; i >= 0; --i) { if (buf[i] == ' ' || buf[i] == '\t' || buf[i] == '\n') buf[i] = '\0'; else break; } // do not save empty line when whitespace is deleted if (strlen(buf) == 0) continue; struct str_elem *se = malloc (sizeof(struct str_elem)); char *line = malloc ((strlen(buf)+1) * sizeof(char)); if (se == NULL || line == NULL) { if (se != NULL) free (se); if (line != NULL) free (line); while (!q_empty (q)) { struct q_elem *e = q_delete(q); se = q_entry (e, struct str_elem, elem); if (se->line != NULL) free(se->line); free(se); } free (q); puts("[FILEIO] MEMORY INSUFFICIENT"); return NULL; } strcpy (line, buf); se->line = line; q_insert (q, &se->elem); } fclose(fp); return q; }
srvr_enque_mid_dncmd(UBUF *ubp) /* dn cmd while up image is being transmitted*/ { int htyp, hlen, clen; time_t tim; BYTE buf[MAX_NODE_PSIZE]; QUEUE *q; PKBH *pkbh; SV_D20("enque_mid_dncmd(0) : entry \n"); if ((htyp = srvr_packet_head_peek(ubp, &hlen)) <= 0) return(-1); if ((clen = srvr_dncmd_packet_read(ubp, buf, hlen, htyp)) <= 0) return(-1); srvr_enque_dncmd(htyp, hlen, clen, buf); q = q_by_htype(UP_NORM_IG1); while(pkbh = q_delete(q)) { Mfree(pkbh); q->taway++; } q = q_by_htype(UP_UGNT_IG1); while(pkbh = q_delete(q)) { Mfree(pkbh); q->taway++; } q = q_by_htype(UP_NORM_IG2); while(pkbh = q_delete(q)) { Mfree(pkbh); q->taway++; } q = q_by_htype(UP_UGNT_IG2); while(pkbh = q_delete(q)) { Mfree(pkbh); q->taway++; } q = q_by_htype(UP_TNOR_IG1); while(pkbh = q_delete(q)) { Mfree(pkbh); q->taway++; } time(&tim); SV_D22("enque_mid_dncmd(1) : recv : DNCMD_PACKT(%.2x)\n", htyp, ctime(&tim)); }
int main() { int q[MAX_Q]; int front; int rear; q_init(q, MAX_Q, &front, &rear); q_print(q, MAX_Q, &front, &rear); q_insert(q, MAX_Q, &front, &rear, 10); q_print(q, MAX_Q, &front, &rear); q_insert(q, MAX_Q, &front, &rear, 20); q_print(q, MAX_Q, &front, &rear); q_insert(q, MAX_Q, &front, &rear, 30); q_print(q, MAX_Q, &front, &rear); printf("Val = %d\n", q_delete(q, MAX_Q, &front, &rear)); printf("Val = %d\n", q_delete(q, MAX_Q, &front, &rear)); printf("Val = %d\n", q_delete(q, MAX_Q, &front, &rear)); q_insert(q, MAX_Q, &front, &rear, 40); q_print(q, MAX_Q, &front, &rear); q_insert(q, MAX_Q, &front, &rear, 50); q_print(q, MAX_Q, &front, &rear); printf("Val = %d\n", q_delete(q, MAX_Q, &front, &rear)); q_insert(q, MAX_Q, &front, &rear, 60); q_print(q, MAX_Q, &front, &rear); printf("Val = %d\n", q_delete(q, MAX_Q, &front, &rear)); printf("Val = %d\n", q_delete(q, MAX_Q, &front, &rear)); return 0; }
void free_file (struct queue *file) { if (file == NULL) return; while (!q_empty (file)) { struct q_elem *e = q_delete (file); struct str_elem *se = q_entry (e, struct str_elem, elem); if (se->line != NULL) free (se->line); free (se); } free (file); }
int main(int argc, char *argv[]) { u_long args[] = { 1, 2, 3, 4 }, msgbuf[4], count; int ret, n; copperplate_init(argc, argv); traceobj_init(&trobj, argv[0], sizeof(tseq) / sizeof(int)); ret = q_create("QUEUE", Q_NOLIMIT, 0, &qid); traceobj_assert(&trobj, ret == SUCCESS); ret = t_create("TSKA", 21, 0, 0, 0, &tidA); traceobj_assert(&trobj, ret == SUCCESS); ret = t_create("TSKB", 20, 0, 0, 0, &tidB); traceobj_assert(&trobj, ret == SUCCESS); ret = t_start(tidA, 0, task_A, args); traceobj_assert(&trobj, ret == SUCCESS); ret = t_start(tidB, 0, task_B, args); traceobj_assert(&trobj, ret == SUCCESS); for (n = 0; n < 3; n++) { msgbuf[0] = n + 1; msgbuf[1] = n + 2; msgbuf[2] = n + 3; msgbuf[3] = n + 4; count = 0; traceobj_mark(&trobj, 7); ret = q_broadcast(qid, msgbuf, &count); traceobj_assert(&trobj, ret == SUCCESS && count == 2); } traceobj_mark(&trobj, 8); traceobj_join(&trobj); traceobj_verify(&trobj, tseq, sizeof(tseq) / sizeof(int)); ret = q_delete(qid); traceobj_assert(&trobj, ret == SUCCESS); exit(0); }
void q_sync(int add_to) { int i; DBG_Q("q_sync: add_to = %d\n", add_to); DBG_Q("q_sync: todo_count = %d\n", todo_count); for (i = 0; i < todo_count; i++) { assert(todo[i].fd >= 0 && todo[i].fd <= max_size); if (todo[i].todo == TODO_ADD) { if (add_to == Q_ADD_TO_FRONT) { q_add_to_front(todo[i].fd); } else if (add_to == Q_ADD_TO_REAR) { q_add_to_rear(todo[i].fd); } } else if (todo[i].todo == TODO_DELETE) { q_delete(todo[i].fd); } } todo_count = 0; }
int do_srvr_interface(UBUF *ubp, int first) { int htyp, hlen, clen, ilen, eflag, bflag, odr, nego_seq, end; long int tim; time_t time, stime = 0; BYTE buf[MAX_NODE_PSIZE+1], *ip; BYTE *fmw; QUEUE *q; PKBH *pkbh; PKBUC *pkbuc; PKBUI *pkbui; SV_D20("do_srvr_interface(1)...\n"); sigset(SIGINT, sig_int); sigset(SIGPIPE, sig_pipe); if (first) { if (srvr_write_nego_packet(ubp, gtway_start) < 0) { /* GTWAY_START */ ubp_flush(ubp); return(-1); } } for (nego_seq = eflag = bflag = 0; !eflag && nego_seq < 3; nego_seq++) { switch(nego_seq) { case 0: if (srvr_write_nego_packet(ubp, req_to_rcv2) < 0) /* REQ_TO_RCV2 */ eflag++; break; case 1: if (!Srvr_gwtm_frq || (Srvr_conn_cnt % Srvr_gwtm_frq && !first)) continue; // skip time request phase if (srvr_write_nego_packet(ubp, req_to_time) < 0){/* REQ_TO_TIME */ eflag++; break; // proc the response at out of switch } if (srvr_write_nego_packet(ubp, req_to_cntd) < 0) /* REQ_TO_CNTD */ eflag++; break; // proc the response at out of switch case 2: if (Srvr_gwst_frq && (Srvr_conn_cnt % Srvr_gwst_frq) == 0) { if (srvr_write_dta_of_gtwy(ubp) < 0) { eflag++; break; } } for (odr = 1; !eflag && odr <= MAX_UORDER; odr++) { /* upwards */ if (!(q = q_by_order(odr))) continue; while(!eflag && (pkbh = q_delete(q))) { if (!(q->flag & Q_IMAGE)) { pkbuc = (PKBUC *)pkbh; SV_D23("\n---> %.2x,%.2x,%.2x\n", pkbuc->b_type, pkbuc->h_mlen, pkbuc->h_mlen+SRVU_HEADLN_CMD); if ((*srvr_ubp_write)(ubp, pkbuc->b_gwid, pkbuc->h_mlen + SRVU_HEADLN_CMD) > 0) { q->tsend++; q->tfail = 0; SV_D12("gtwy-->srvr : %s[%.2x]\n", get_pdu_name(pkbuc->b_type), pkbuc->b_type); Mfree(pkbuc); } else { if (++(pkbuc->h_nretry) > q->maxrt) { q->taway++; L01("do_srvr_interface(9): send: CMDTA_PACKT(%.2x) away.\n", pkbuc->b_type); SV_D01("do_srvr_interface(9): send: CMDTA_PACKT(%.2x) away.\n", pkbuc->b_type); Mfree(pkbuc); } else { q->tfail++; q_insert_bak((PKBH *)pkbuc, q); L01("do_srvr_interface(9): send: CMDTA_PACKT(%.2x) fail.\n", pkbuc->b_type); SV_D01("do_srvr_interface(9): send: CMDTA_PACKT(%.2x) fail.\n", pkbuc->b_type); } eflag++; } } else { pkbui = (PKBUI *)pkbh; SV_D23("\n---> %.2x,%.8x,%.8x\n", pkbui->b_type, pkbui->h_mlen, pkbui->h_mlen+SRVU_HEADLN_IMG); if ((*srvr_ubp_write)(ubp, pkbui->b_gwid, pkbui->h_mlen + SRVU_HEADLN_IMG) > 0) { q->tsend++; q->tfail = 0; SV_D12("gtwy-->srvr : %s[%.2x]\n", get_pdu_name(pkbui->b_type), pkbui->b_type); Mfree(pkbui); if (srvr_write_nego_packet(ubp, req_to_cntd) < 0) eflag++; } else { L03("do_srvr_interface(B): send: IMAGE_PACKT(%.2x):%.8x,%d: fail.\n", pkbui->b_type, pkbui->h_mlen-NDEU_HEADLN_IMG-2, pkbui->h_mlen-NDEU_HEADLN_IMG-2); SV_D03("do_srvr_interface(B): send: IMAGE_PACKT(%.2x):%.8x,%d: fail.\n", pkbui->b_type, pkbui->h_mlen-NDEU_HEADLN_IMG-2, pkbui->h_mlen-NDEU_HEADLN_IMG-2); if (++(pkbui->h_nretry) > q->maxrt) { q->taway++; L01("do_srvr_interface(B): send: CMDTA_PACKT(%.2x) away.\n", pkbui->b_type); SV_D01("do_srvr_interface(B): send: CMDTA_PACKT(%.2x) away.\n", pkbui->b_type); Mfree(pkbui); } else { q->tfail++; q_insert_bak((PKBH *)pkbui, q); L01("do_srvr_interface(B_2): send: CMDTA_PACKT(%.2x) fail.\n", pkbui->b_type); SV_D01("do_srvr_interface(B_2): send: CMDTA_PACKT(%.2x) fail.\n", pkbui->b_type); } eflag++; } } } // end while } // end for } // end switch for (end = 0; nego_seq < 2 && !end && !eflag; ) { if ((htyp = srvr_packet_head_peek(ubp, &hlen)) < 0) { eflag++; break; /* hlen : ln(1) --> sizeof binary body */ } SV_D12("gtwy<--srvr : %s[%.2x]\n", get_pdu_name(htyp), htyp); if (htyp != DN_NORM_FMW && htyp != DN_GTWY_FMW) { if ((clen = srvr_dncmd_packet_read(ubp, buf, hlen, htyp)) <= 0) { eflag++; break; /* clen = id(1)+length(1)+address(2)+data(n)+escs */ } } else { // length == 4 byte fmw = (BYTE *)Malloc(MAX_FIRMW_SIZE); if ((clen = srvr_dnfmw_packet_read(ubp, fmw, hlen)) <= 0) { Mfree(fmw); /* clen = did(1)+data(n) = 1 + hlen */ eflag++; break; } } switch(htyp) { case DN_NORM_CMD: srvr_enque_dncmd(htyp, hlen, clen, buf); continue; case DN_NORM_FMW: srvr_enque_dnfmw(htyp, hlen, clen, fmw); Mfree(fmw); continue; case DN_GTWY_FMW: if (srvr_enfuse_gtwy(htyp, hlen, clen, fmw) < 0) eflag++; else bflag++; Mfree(fmw); continue; case SET_GW_TIME: SV_D20("time = "); SV_MDH(buf + SRVD_ADROFF_CMD, 4); tim = get_bin_p2_n(buf + SRVD_ADROFF_CMD); /* should be SRVD_DTAOFF_CMD */ SV_D21("fd Set OK...[%d]\n", tim); set_system_time(tim); continue; case REQ_GW_STAT: if (srvr_write_dta_of_gtwy(ubp) < 0) eflag++; end++; break; case END_OF_SND2: end++; break; default : L01("do_srvr_interface(9) : recv: unknown type(%.2x)\n", htyp); SV_D01("do_srvr_interface(9) : recv: unknown type(%.2x)\n", htyp); end++; eflag++; } // end switch } // end for } // end for Srvr_conn_cnt++; SV_D01("Srvr_conn_cnt = %d\n", Srvr_conn_cnt); if (!eflag) { srvr_write_nego_packet(ubp, end_of_snd3); /* END_OF_SND3 */ if (bflag){ if(Cdma_uart_use) { cdma_disc_tcpip(ubp); cdma_disc_circuit(ubp); } else { close(ubp->ufd); if(Cdsk_pppd_use) { wakeup_pppd(PPPD_CTRL_PWROFF); } } sleep(3); SV_D00("do_srvr_interface(A) : Restart Egtwy..\n"); srvr_reboot_gtwy(); /* no rturn */ } } ubp_flush(ubp); if (!eflag) return(1); else return(-1); }
/* START FUNC DECL */ int t1f1t2f2opt3f3( char *t1, char *f1, char *t2, char *f2, char *op, char *options, char *t3, char *f3 ) /* STOP FUNC DECL */ { int status = 0; char *f1_X = NULL; size_t f1_nX = 0; char *f2_X = NULL; size_t f2_nX = 0; char *f3_X = NULL; size_t f3_nX = 0; int t1_id = INT_MIN, t2_id = INT_MIN, t3_id = INT_MIN; int f1_id = INT_MIN, f2_id = INT_MIN, f3_id = INT_MIN; int nn_f1_id = INT_MIN, nn_f2_id = INT_MIN; TBL_REC_TYPE t1_rec, t2_rec, t3_rec; FLD_REC_TYPE f1_rec, nn_f1_rec; FLD_REC_TYPE f2_rec, nn_f2_rec; FLD_REC_TYPE f3_rec; FLD_TYPE f3_type = undef_fldtype; long long nR1 = INT_MIN, nR2 = INT_MIN; long long nR3 = INT_MIN, nR3_allocated = INT_MIN; int f3_fldsz = INT_MAX; size_t filesz; int ddir_id = -1, fileno = -1; /*----------------------------------------------------------------*/ if ( ( t1 == NULL ) || ( *t1 == '\0' ) ) { go_BYE(-1); } if ( ( f1 == NULL ) || ( *f1 == '\0' ) ) { go_BYE(-1); } if ( ( t2 == NULL ) || ( *t2 == '\0' ) ) { go_BYE(-1); } if ( ( f2 == NULL ) || ( *f2 == '\0' ) ) { go_BYE(-1); } if ( ( op == NULL ) || ( *op == '\0' ) ) { go_BYE(-1); } if ( ( f3 == NULL ) || ( *f3 == '\0' ) ) { go_BYE(-1); } if ( strcmp(t1, t3) == 0 ) { go_BYE(-1); } if ( ( t3 == NULL ) || ( *t3 == '\0' ) ) { go_BYE(-1); } if ( strcmp(t2, t3) == 0 ) { go_BYE(-1); } /*--------------------------------------------------------*/ status = is_tbl(t1, &t1_id, &t1_rec); cBYE(status); if ( t1_id < 0 ) { go_BYE(-1); } nR1 = t1_rec.nR; /*--------------------------------------------------------*/ status = is_fld(NULL, t1_id, f1, &f1_id, &f1_rec, &nn_f1_id, &nn_f1_rec); cBYE(status); if ( f1_id < 0 ) { go_BYE(-1); } status = get_data(f1_rec, &f1_X, &f1_nX, false); cBYE(status); /*--------------------------------------------------------*/ status = is_tbl(t2, &t2_id, &t2_rec); cBYE(status); if ( t2_id < 0 ) { go_BYE(-1); } nR2 = t2_rec.nR; /*--------------------------------------------------------*/ status = is_fld(NULL, t2_id, f2, &f2_id, &f2_rec, &nn_f2_id, &nn_f2_rec); cBYE(status); if ( f2_id < 0 ) { go_BYE(-1); } status = get_data(f2_rec, &f2_X, &f2_nX, false); cBYE(status); /*--------------------------------------------------------*/ /* f1, f2 must be sorted ascending */ if ( f1_rec.srttype != ascending ) { go_BYE(-1); } if ( f2_rec.srttype != ascending ) { go_BYE(-1); } /* Have not implemented case where f1 has null field */ if ( nn_f1_id >= 0 ) { go_BYE(-1); } if ( nn_f2_id >= 0 ) { go_BYE(-1); } if ( f1_rec.fldtype != f2_rec.fldtype ) { go_BYE(-1); } switch ( f1_rec.fldtype ) { case I4 : case I8 : break; default : go_BYE(-1); break; } f3_type = f1_rec.fldtype; status = get_fld_sz(f3_type, &f3_fldsz); cBYE(status); if ( strcmp(op, "intersection") == 0 ) { nR3_allocated = min(nR1 , nR2); } else if ( strcmp(op, "a_minus_b") == 0 ) { nR3_allocated = nR1; /* upper bound. Truncate this later */ } else if ( ( strcmp(op, "union") == 0 ) || ( strcmp(op, "pvalcalc") == 0 ) ) { nR3_allocated = nR1 + nR2; /* nR1 + nR2 is upper bound. Reduce later */ } else { go_BYE(-1); } filesz = f3_fldsz * nR3_allocated; status = mk_temp_file(filesz, &ddir_id, &fileno); cBYE(status); status = q_mmap(ddir_id, fileno, &f3_X, &f3_nX, true); cBYE(status); if ( strcmp(op, "intersection") == 0 ) { switch ( f1_rec.fldtype ) { case I4 : status = intersection_I4((int *)f1_X, nR1, (int *)f2_X, nR2, (int *)f3_X, &nR3); break; case I8 : status = intersection_I8((long long *)f1_X, nR1, (long long *)f2_X, nR2, (long long *)f3_X, &nR3); break; default : go_BYE(-1); break; } cBYE(status); } else if ( strcmp(op, "a_minus_b") == 0 ) { switch ( f1_rec.fldtype ) { case I4 : a_minus_b_I4((int *)f1_X, nR1, (int *)f2_X, nR2, (int *)f3_X, &nR3); break; case I8 : a_minus_b_I8((long long *)f1_X, nR1, (long long *)f2_X, nR2, (long long *)f3_X, &nR3); break; default : go_BYE(-1); break; } cBYE(status); } else if ( ( strcmp(op, "union") == 0 ) || ( strcmp(op, "pvalcalc") == 0 ) ) { unsigned long long mask = 0; if ( strcmp(op, "pvalcalc") == 0 ) { bool is_null = false; status = extract_UI8(options, "mask=[", "]", &mask, &is_null); if ( is_null ) { go_BYE(-1); } } switch ( f1_rec.fldtype ) { case I4 : status = union_I4((int *)f1_X, nR1, (int *)f2_X, nR2, (int *)f3_X, &nR3, (unsigned int)mask); cBYE(status); break; case I8 : status = union_I8((long long *)f1_X, nR1, (long long *)f2_X, nR2, (long long *)f3_X, &nR3, (unsigned long long)mask); cBYE(status); break; default : go_BYE(-1); break; } } else { go_BYE(-1); } rs_munmap(f3_X, f3_nX); if ( nR3 == 0 ) { status = q_delete(ddir_id, fileno); cBYE(status); ddir_id = fileno = -1; go_BYE(0); } else if ( nR3 < nR3_allocated ) { status = q_trunc(ddir_id, fileno, (nR3 * f3_fldsz)); cBYE(status); } else if ( nR3 > nR3_allocated ) { go_BYE(-1); } char str_nR3[32]; sprintf(str_nR3, "%lld", nR3); status = add_tbl(t3, str_nR3, &t3_id, &t3_rec); cBYE(status); zero_fld_rec(&f3_rec); f3_rec.fldtype = f3_type; status = add_fld(t3_id, f3, ddir_id, fileno, &f3_id, &f3_rec); cBYE(status); /* Since f1 and f2 are sorted ascending, so must f3 be */ if ( ( strcmp(op, "union") == 0 ) || ( strcmp(op, "intersection") == 0 ) || ( strcmp(op, "a_minus_b") == 0 ) ) { status = int_set_meta(t3_id, f3_id, "srttype", "ascending", true); cBYE(status); } /*-----------------------------------------------------------*/ BYE: rs_munmap(f1_X, f1_nX); rs_munmap(f2_X, f2_nX); rs_munmap(f3_X, f3_nX); return status ; }
// last review 9/5/2013 //--------------------------------------------------------------- // START FUNC DECL int xfer( char *src_tbl, char *src_fld, char *dst_tbl, char *dst_idx, // this is an index into the source table char *dst_fld ) // STOP FUNC DECL { int status = 0; TBL_REC_TYPE src_tbl_rec, dst_tbl_rec; FLD_REC_TYPE src_fld_rec, dst_idx_meta, dst_fld_rec; FLD_REC_TYPE nn_src_fld_rec, nn_dst_idx_meta, nn_dst_fld_rec; char strbuf[32]; int dict_tbl_id; long long src_nR, dst_nR; char *src_fld_X = NULL; size_t src_fld_nX = 0; char *dst_fld_X = NULL; size_t dst_fld_nX = 0; char *dst_idx_X = NULL; size_t dst_idx_nX = 0; char *nn_src_fld_X = NULL; size_t nn_src_fld_nX = 0; char *nn_dst_idx_X = NULL; size_t nn_dst_idx_nX = 0; char *nn_dst_fld_X = NULL; size_t nn_dst_fld_nX = 0; int src_tbl_id = INT_MIN, dst_tbl_id = INT_MIN; int src_fld_id = INT_MIN, nn_src_fld_id = INT_MIN; int dst_idx_id = INT_MIN, nn_dst_idx_id = INT_MIN; int dst_fld_id = INT_MIN, nn_dst_fld_id = INT_MIN; //---------------------------------------------------------------- if ( ( src_tbl == NULL ) || ( *src_tbl == '\0' ) ) { go_BYE(-1); } if ( ( dst_tbl == NULL ) || ( *dst_tbl == '\0' ) ) { go_BYE(-1); } if ( ( src_fld == NULL ) || ( *src_fld == '\0' ) ) { go_BYE(-1); } if ( ( dst_idx == NULL ) || ( *dst_idx == '\0' ) ) { go_BYE(-1); } if ( ( dst_fld == NULL ) || ( *dst_fld == '\0' ) ) { go_BYE(-1); } if ( strcmp(dst_idx, dst_fld) == 0 ) { go_BYE(-1); } //---------------------------------------------------------------- status = is_tbl(src_tbl, &src_tbl_id, &src_tbl_rec); cBYE(status); chk_range(src_tbl_id, 0, g_n_tbl); src_nR = g_tbls[src_tbl_id].nR; status = is_fld(NULL, src_tbl_id, src_fld, &src_fld_id, &src_fld_rec, &nn_src_fld_id, &nn_src_fld_rec); cBYE(status); chk_range(src_fld_id, 0, g_n_fld); status = get_data(src_fld_rec, &src_fld_X, &src_fld_nX, false); cBYE(status); status = is_tbl(dst_tbl, &dst_tbl_id, &dst_tbl_rec); cBYE(status); chk_range(dst_tbl_id, 0, g_n_tbl); dst_nR = g_tbls[dst_tbl_id].nR; status = is_fld(NULL, dst_tbl_id, dst_idx, &dst_idx_id, &dst_idx_meta, &nn_dst_idx_id, &nn_dst_idx_meta); cBYE(status); chk_range(dst_idx_id, 0, g_n_fld); status = get_data(dst_idx_meta, &dst_idx_X, &dst_idx_nX, false); cBYE(status); if ( nn_src_fld_id >= 0 ) { status = get_data(nn_src_fld_rec, &nn_src_fld_X, &nn_src_fld_nX, false); cBYE(status); } if ( nn_dst_idx_id >= 0 ) { status = get_data(nn_dst_idx_meta, &nn_dst_idx_X, &nn_dst_idx_nX, false); cBYE(status); } //---------------------------------------------------------------- // allocate space for output int fldsz = 0; size_t filesz = 0; int ddir_id = -1, fileno = -1; int nn_ddir_id = -1, nn_fileno = -1; if ( src_fld_rec.fldtype == SC ) { int len = src_fld_rec.len; if ( len <= 0 ) { go_BYE(-1); } filesz = (len+1) * dst_nR; } else if ( ( src_fld_rec.fldtype == SV ) ||( src_fld_rec.fldtype == B ) ) { fprintf(stderr, "NOT IMPLEMENTED\n"); go_BYE(-1); } else { status = get_fld_sz(src_fld_rec.fldtype, &fldsz); cBYE(status); filesz = fldsz * dst_nR; } status = mk_temp_file(filesz, &ddir_id, &fileno); cBYE(status); status = q_mmap(ddir_id, fileno, &dst_fld_X, &dst_fld_nX, true); cBYE(status); if ( nn_src_fld_id < 0 ) { // No nulls in source means no nulls possible in destination } else { // may not need the nn field but will discover this only later status = get_fld_sz(I1, &fldsz); cBYE(status); filesz = fldsz * dst_nR; status = mk_temp_file(filesz, &nn_ddir_id, &nn_fileno); cBYE(status); status = q_mmap(nn_ddir_id, nn_fileno, &nn_dst_fld_X, &nn_dst_fld_nX,true); cBYE(status); } //---------------------------------------------------------------- switch ( src_fld_rec.fldtype ) { #include "incl_xfer_I1.c" #include "incl_xfer_I2.c" #include "incl_xfer_I4.c" #include "incl_xfer_I8.c" #include "incl_xfer_F4.c" #include "incl_xfer_F8.c" case SC : switch ( dst_idx_meta.fldtype ) { case I4 : xfer_SC_I4(src_fld_X, src_fld_rec.len, src_nR, dst_idx_X, nn_dst_idx_X, dst_nR, dst_fld_X); break; default : go_BYE(-1); break; } break; default : go_BYE(-1); break; } #define BUFLEN 32 char buf[BUFLEN], buf2[BUFLEN]; long long nn_dst_nR; zero_fld_rec(&dst_fld_rec); dst_fld_rec.fldtype = src_fld_rec.fldtype; status = add_fld(dst_tbl_id, dst_fld, ddir_id, fileno, &dst_fld_id, &dst_fld_rec); cBYE(status); // Find out whether an nn field is really needed status = vec_f_to_s(nn_dst_fld_X, I1, NULL, dst_nR, "sum", buf, BUFLEN); cBYE(status); status = read_nth_val(buf, ":", 0, buf2, BUFLEN); cBYE(status); status = stoI8(buf2, &nn_dst_nR); cBYE(status); if ( dst_nR == nn_dst_nR ) { // nn field not needed status = q_delete(nn_ddir_id, nn_fileno); cBYE(status); } else { zero_fld_rec(&nn_dst_fld_rec); nn_dst_fld_rec.fldtype = I1; status = add_aux_fld(NULL, dst_tbl_id, NULL, dst_fld_id, nn_ddir_id, nn_fileno, nn, &nn_dst_fld_id, &nn_dst_fld_rec); } status = int_get_meta(src_tbl_id, src_fld_id, "dict_tbl_id", strbuf); cBYE(status); status = stoI4(strbuf, &dict_tbl_id); cBYE(status); if ( dict_tbl_id >= 0 ) { status = int_set_meta(dst_tbl_id, dst_fld_id, "dict_tbl_id", strbuf, true); cBYE(status); } BYE: rs_munmap(src_fld_X, src_fld_nX); rs_munmap(dst_idx_X, dst_idx_nX); rs_munmap(dst_fld_X, dst_fld_nX); rs_munmap(nn_src_fld_X, nn_src_fld_nX); rs_munmap(nn_dst_idx_X, nn_dst_idx_nX); rs_munmap(nn_dst_fld_X, nn_dst_fld_nX); return status ; }
int main(void) { // INITIALIZING struct queue cmd_queue; q_init (&cmd_queue); uint8_t *mem = calloc (__MEMORY_SIZE, sizeof(uint8_t)); char *input = malloc (sizeof(char)*__INPUT_SIZE); char *cmd = malloc (sizeof(char)*__CMD_SIZE); char *filename = malloc (sizeof(char)*__FILENAME_SIZE); if (mem == NULL || input == NULL || filename == NULL || cmd == NULL) { puts("MEMORY INSUFFICIENT"); goto memory_clear; } if (!init_oplist (__OPCODE_FILENAME)) { puts("OPCODE LIST INITIALIZATION FAILED."); goto memory_clear; } // COMMAND PROCESSING while (true) { int i; struct q_elem *qe; uint8_t value; uint32_t start, end; DIR *dirp = NULL; struct dirent *dir = NULL; char check[2]; bool is_valid_cmd = false; char *tok = NULL; printf("%s", __SHELL_FORM); if (!get_chars(input, __INPUT_SIZE)) goto memory_clear; // Processing input string snprintf((char *) __CMD_FORMAT, __CMD_FORMAT_SIZE, "%%%ds", __CMD_SIZE - 1); if (sscanf(input, (const char *) __CMD_FORMAT, cmd)!=1) cmd[0] = '\0'; // Switching with commands switch(get_cmd_index(cmd)) { case CMD_HELP: if(sscanf(input, "%*s %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } puts(__HELP_FORM); is_valid_cmd = true; break; case CMD_DIR: if(sscanf(input, "%*s %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } // open directory and read through all elem. i = 1; dirp = opendir("."); dir = readdir(dirp); for(; dir!=NULL; dir = readdir(dirp)) { struct stat st; if(stat((const char*) dir->d_name, &st)!=0) { puts("FILE NOT FOUND"); goto memory_clear; } // FIX: ignore . and .. if(_SAME_STR(dir->d_name, ".") || _SAME_STR(dir->d_name, "..")) continue; printf("%20s", dir->d_name); if(S_ISDIR(st.st_mode)) // is Directory? putchar('/'); else if( (st.st_mode & S_IXUSR) // is exe? || (st.st_mode & S_IXGRP) || (st.st_mode & S_IXOTH) ) putchar('*'); putchar('\t'); // print newline after 3 elements if((i++)%3==0) putchar('\n'); } if((i-1)%3!=0) putchar('\n'); is_valid_cmd = true; break; case CMD_QUIT: if(sscanf(input, "%*s %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } is_valid_cmd = true; goto memory_clear; case CMD_HISTORY: if(sscanf(input, "%*s %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } qe = q_begin (&cmd_queue); i = 1; // print every formatted history for (; qe!=q_end(&cmd_queue); qe=q_next(qe)) printf("%-4d %s\n", i++, q_entry(qe, struct cmd_elem, elem)->cmd); printf("%-4d %s\n", i, input); is_valid_cmd = true; break; case CMD_DUMP: switch(sscanf(input, "%s %x , %x", cmd, &start, &end)) { case 1: if(sscanf(input, "%*s %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } start = get_location (0, false); end = start + 0x10 * 10 - 1; // if end is too large, point to end and go 0 if ( end >= __MEMORY_SIZE ) end = __MEMORY_SIZE - 1; hexdump (mem, start, end); if ( end == __MEMORY_SIZE - 1) get_location (0, true); else get_location (end + 1, true); is_valid_cmd = true; break; case 2: if(sscanf(input, "%*s %*x %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } if (start >= __MEMORY_SIZE) { puts("OUT OF MEMORY BOUNDS."); break; } end = start + 0x10 * 10 - 1; // if end is too large, point to end and go 0 if ( end >= __MEMORY_SIZE ) end = __MEMORY_SIZE - 1; hexdump (mem, start, end); if ( end == __MEMORY_SIZE - 1) get_location (0, true); else get_location (end + 1, true); is_valid_cmd = true; break; case 3: if(sscanf(input, "%*s %*x , %*x %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } if (!(start<=end && end<__MEMORY_SIZE)) { puts("OUT OF MEMORY BOUNDS."); break; } hexdump (mem, start, end); // if end is too large, point to end and go 0 if ( end == __MEMORY_SIZE - 1) get_location (0, true); else get_location (end + 1, true); is_valid_cmd = true; break; default: puts("WRONG INSTRUCTION"); break; } break; case CMD_EDIT: switch(sscanf(input, "%s %x , %hhx", cmd, &start, &value)) { case 3: if(sscanf(input, "%*s %*x , %*x %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } hexfill (mem, __MEMORY_SIZE, start, start, value); is_valid_cmd = true; break; default: puts("WRONG INSTRUCTION"); break; } break; case CMD_FILL: switch(sscanf(input, "%s %x , %x , %hhx", cmd, &start, &end, &value)) { case 4: if(sscanf(input, "%*s %*x , %*x , %*x %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } hexfill (mem, __MEMORY_SIZE, start, end, value); is_valid_cmd = true; break; default: puts("WRONG INSTRUCTION"); break; } break; case CMD_RESET: if(sscanf(input, "%*s %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } // equivalent to fill 0, __MEMORY_SIZE-1 hexfill (mem, __MEMORY_SIZE, 0, __MEMORY_SIZE - 1, 0); is_valid_cmd = true; break; case CMD_OPCODE: switch(sscanf(input, "%*s %s", cmd)) { case 1: if(sscanf(input, "%*s %*s %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } i = find_oplist (cmd); if (i != -1) printf("opcode is %02X\n", i); else { printf("%s: NO SUCH OPCODE\n", cmd); is_valid_cmd = false; } break; default: puts("WRONG INSTRUCTION"); break; } break; case CMD_OPCODELIST: if(sscanf(input, "%*s %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } print_oplist (); is_valid_cmd = true; break; case CMD_ASSEMBLE: // Processing input string snprintf((char *) __CMD_FORMAT, __CMD_FORMAT_SIZE, "%%%ds %%%ds %%1s", __CMD_SIZE - 1, __FILENAME_SIZE - 1); if (sscanf(input, (const char *) __CMD_FORMAT, cmd, filename, check)!=2) { puts("WRONG INSTRUCTION"); break; } if (!is_file((const char*)filename)) { puts("FILE NOT FOUND"); break; } is_valid_cmd = assemble_file (filename); break; case CMD_TYPE: // Processing input string snprintf((char *) __CMD_FORMAT, __CMD_FORMAT_SIZE, "%%%ds %%%ds %%1s", __CMD_SIZE - 1, __FILENAME_SIZE - 1); if (sscanf(input, (const char *) __CMD_FORMAT, cmd, filename, check)!=2) { puts("WRONG INSTRUCTION"); break; } if (!is_file((const char*)filename)) { puts("FILE NOT FOUND"); break; } else { print_file((const char*)filename); is_valid_cmd = true; } break; case CMD_SYMBOL: if(sscanf(input, "%*s %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } print_symbol_table (); is_valid_cmd = true; break; case CMD_PROGADDR: if(sscanf(input, "%*s %*x %1s", check) == 1 || sscanf(input, "%*s %x", &i) != 1) { puts("WRONG INSTRUCTION"); break; } if (i < 0 || i >= __MEMORY_SIZE - 1) { puts("INVALID PROGRAM ADDRESS"); break; } set_progaddr ((uint32_t) i); is_valid_cmd = true; break; case CMD_LOADER: init_loader (); tok = strtok (input, " "); while ( (tok = strtok (NULL, " ")) != NULL) { if (!is_file (tok)) { printf ("[%s]: INVALID FILE\n", tok); free_loader (); break; } if (!add_obj_loader (tok)) { printf ("[%s]: LOADER FAILED\n", tok); free_loader (); break; } } // if normally added if (tok == NULL) { // address __MEMORY_SIZE is reserved for boot if (get_proglen()+get_progaddr()>=__MEMORY_SIZE-1) { puts ("PROGRAM IS TOO BIG: LOADER FAILED"); free_loader (); break; } if (!run_loader (mem)) { puts ("LOADER FAILED"); free_loader (); break; } print_load_map (); } free_loader (); is_valid_cmd = true; break; case CMD_RUN: if(sscanf(input, "%*s %1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } if (!init_run ()) { puts ("RUN FAILED"); free_run (); break; } run (mem); free_run (); is_valid_cmd = true; break; case CMD_BP: if(sscanf(input, "%*s %1s", check) != 1) { print_bp (); is_valid_cmd = true; break; } if(sscanf(input, "%*s %6s %1s", cmd, check) == 2 || sscanf(input, "%*s %6s", cmd) != 1) { puts("WRONG INSTRUCTION"); break; } if (_SAME_STR(cmd, "clear")) { puts ("\t[ok] clear all breakpoints"); free_bp (); is_valid_cmd = true; break; } if(sscanf(input, "%*s %*x %1s", check) == 1 || sscanf(input, "%*s %x", &start) != 1) { puts("WRONG INSTRUCTION"); break; } if (start >= __MEMORY_SIZE - 1) { puts ("INVALID BREAKPOINT ADDRESS"); break; } if (add_bp (start)) printf ("\t[ok] create breakpoint %x\n", start); is_valid_cmd = true; break; default: if(sscanf(input, "%1s", check) == 1) { puts("WRONG INSTRUCTION"); break; } } if (is_valid_cmd) { // Saving commands struct cmd_elem *e = malloc(sizeof(struct cmd_elem)); if (e == NULL) { puts("MEMORY INSUFFICIENT."); goto memory_clear; } e->cmd = malloc(sizeof(char)*(strlen(input)+1)); if (e->cmd == NULL) { puts("MEMORY INSUFFICIENT."); goto memory_clear; } strcpy(e->cmd, input); q_insert (&cmd_queue, &(e->elem)); } } memory_clear: if (mem != NULL) free (mem); if (input != NULL) free (input); if (cmd != NULL) free (cmd); while (!q_empty(&cmd_queue)) { struct q_elem *e = q_delete(&cmd_queue); struct cmd_elem *ce = q_entry(e, struct cmd_elem, elem); if (ce->cmd != NULL) free(ce->cmd); free(ce); } free_oplist (); free_loader (); free_bp (); free_run (); return 0; }
/* START FUNC DECL */ int get_t2f2_val( char *t1, char *lnk1, char *t2, char *lnk2, char *t2f2, /* field in t2 */ char *t1f2 /* field in t1 */ ) /* STOP FUNC DECL */ { int status = 0; char *t2f2_X = NULL; size_t n_t2f2_X = 0; char *nn_t2f2_X = NULL; size_t nn_n_t2f2_X = 0; char *X = NULL; size_t nX = 0; char *nn_X = NULL; size_t nn_nX = 0; char *X1 = NULL; size_t nX1 = 0; char *X2 = NULL; size_t nX2 = 0; char *nn_X1 = NULL; size_t nn_nX1 = 0; char *nn_X2 = NULL; size_t nn_nX2 = 0; TBL_REC_TYPE t1_rec, t2_rec; FLD_REC_TYPE lnk1_rec, nn_lnk1_rec; int lnk1_id, nn_lnk1_id; FLD_REC_TYPE lnk2_rec, nn_lnk2_rec;int lnk2_id, nn_lnk2_id; FLD_REC_TYPE t2f2_rec, nn_t2f2_rec; int t2f2_id, nn_t2f2_id; FLD_REC_TYPE t1f2_rec, nn_t1f2_rec; int t1f2_id, nn_t1f2_id; int t1_id, t2_id; long long nR1, nR2; #define BUFLEN 32 char rslt_buf[BUFLEN]; char **Y = NULL; int nY = 0; HT_I8_TYPE *ht = NULL; int sz_ht; // size of hash table int n_ht = 0; // number of occupied entries in hash table /*-------------------------------------------------------------*/ if ( ( t1 == NULL ) || ( *t1 == '\0' ) ) { go_BYE(-1); } if ( ( t2 == NULL ) || ( *t2 == '\0' ) ) { go_BYE(-1); } if ( ( strcmp(t1, t2) == 0 ) && ( strcmp(t1f2, t2f2) == 0 ) ) { go_BYE(-1); } if ( ( lnk1 == NULL ) || ( *lnk1 == '\0' ) ) { go_BYE(-1); } if ( ( lnk2 == NULL ) || ( *lnk2 == '\0' ) ) { go_BYE(-1); } /*-------------------------------------------------------------*/ status = is_tbl(t1, &t1_id, &t1_rec); cBYE(status); chk_range(t1_id, 0, g_n_tbl); nR1 = g_tbls[t1_id].nR; status = is_tbl(t2, &t2_id, &t2_rec); cBYE(status); chk_range(t2_id, 0, g_n_tbl); nR2 = g_tbls[t2_id].nR; /*-------------------------------------------------------------*/ status = is_fld(NULL, t1_id, lnk1, &lnk1_id, &lnk1_rec, &nn_lnk1_id, &nn_lnk1_rec); cBYE(status); chk_range(lnk1_id, 0, g_n_fld); if ( nn_lnk1_id >= 0 ) { status = get_data(nn_lnk1_rec, &nn_X1, &nn_nX1, false); cBYE(status); } status = get_data(lnk1_rec, &X1, &nX1, false); cBYE(status); /*-------------------------------------------------------------*/ status = is_fld(NULL, t2_id, lnk2, &lnk2_id, &lnk2_rec, &nn_lnk2_id, &nn_lnk2_rec); cBYE(status); chk_range(lnk2_id, 0, g_n_fld); if ( nn_lnk2_id >= 0 ) { go_BYE(-1); } status = get_data(lnk2_rec, &X2, &nX2, false); cBYE(status); if ( nn_lnk2_id >= 0 ) { status = get_data(nn_lnk2_rec, &nn_X2, &nn_nX2, false); cBYE(status); } /*-------------------------------------------------------- */ if ( lnk1_rec.fldtype != lnk2_rec.fldtype ) { go_BYE(-1); } /*-------------------------------------------------------- */ status = is_fld(NULL, t2_id, t2f2, &t2f2_id, &t2f2_rec, &nn_t2f2_id, &nn_t2f2_rec); cBYE(status); chk_range(t2f2_id, 0, g_n_fld); status = get_data(t2f2_rec, &t2f2_X, &n_t2f2_X, false); cBYE(status); if ( nn_t2f2_id >= 0 ) { status = get_data(nn_t2f2_rec, &nn_t2f2_X, &nn_n_t2f2_X, false); cBYE(status); } /*--------------------------------------------------------*/ /* Check supported field types */ if ( lnk1_rec.fldtype != I4 ) { go_BYE(-1); } if ( lnk2_rec.fldtype != I4 ) { go_BYE(-1); } if ( t2f2_rec.fldtype != I4 ) { go_BYE(-1); } /*-------------------------------------------------------- */ /* Create space for output */ int fldsz = 0; size_t filesz = 0; int ddir_id = -1, fileno = -1; int nn_ddir_id = -1, nn_fileno = -1; status = get_fld_sz(I4, &fldsz); cBYE(status); filesz = fldsz * nR1; status = mk_temp_file(filesz, &ddir_id, &fileno); status = q_mmap(ddir_id, fileno, &X, &nX, 1); cBYE(status); status = get_fld_sz(I1, &fldsz); cBYE(status); filesz = fldsz * nR1; status = mk_temp_file(filesz, &nn_ddir_id, &nn_fileno); status = q_mmap(nn_ddir_id, nn_fileno, &nn_X, &nn_nX, 1); cBYE(status); /*-------------------------------------------------------- */ bool is_fast = false; bool definitely_has_null_vals = false; long long nn_nR2 = 0; if ( nn_X2 != NULL ) { for ( long long i = 0; i < nR2; i++ ) { if ( nn_X2[i] == TRUE ) { nn_nR2++; } } } else { nn_nR2 = nR2; } if ( nn_nR2 == 0 ) { definitely_has_null_vals = true; assign_const_I4((int *)X, nR1, 0); assign_const_I1((char *)nn_X, nR1, 0); } else { cilkfor ( long long i = 0; i < nR1; i++ ) { int *it2f2 = (int *)t2f2_X; int *I4_lnk1 = (int *)X1; int I4val1; int *I4_lnk2 = (int *)X2; int I4val2; int *out = (int *)X; int outval; char *out_nn = (char *)nn_X; char c_nn; I4val1 = I4_lnk1[i]; /* If the link value is null, then the output value is null */ if ( ( nn_X1 != NULL ) && ( nn_X1[i] == FALSE ) ) { out_nn[i] = FALSE; out[i] = 0; } else { /* We are now looking for I4val1 in the link field of t2 */ if ( is_fast == false ) { outval = 0; c_nn = FALSE; for ( long long j = 0; j < nR2; j++ ) { if ( ( nn_X2 != NULL ) && ( nn_X2[j] == FALSE ) ) { continue; } I4val2 = I4_lnk2[j]; if ( I4val1 == I4val2 ) { if ( ( nn_t2f2_X == NULL ) || (nn_t2f2_X[j] == TRUE ) ) { c_nn = TRUE; } outval = it2f2[j]; break; } } out_nn[i] = c_nn; out[i] = outval; } else { WHEREAMI; status = -1; continue; } } } cBYE(status); #ifdef CILK __cilkrts_end_cilk(); #endif } rs_munmap(X, nX); zero_fld_rec(&t1f2_rec); t1f2_rec.fldtype = I4; status = add_fld(t1_id, t1f2, ddir_id, fileno, &t1f2_id, &t1f2_rec); cBYE(status); if ( definitely_has_null_vals == true ) { /* No need to check */ rs_munmap(nn_X, nn_nX); zero_fld_rec(&nn_t1f2_rec); nn_t1f2_rec.fldtype = I1; status = add_aux_fld(NULL, t1_id, NULL, t1f2_id, nn_ddir_id, nn_fileno, nn, &nn_t1f2_id, &nn_t1f2_rec); cBYE(status); } else { status = vec_f_to_s(nn_X, I1, NULL, nR1, "sum", rslt_buf, BUFLEN); cBYE(status); status = explode(rslt_buf, ':', &Y, &nY); if ( nY != 2 ) { go_BYE(-1); } rs_munmap(nn_X, nn_nX); if ( strcmp(Y[0], Y[1]) == 0 ) { /* num non null values == nR => nn field not needed */ status = q_delete(nn_ddir_id, nn_fileno); cBYE(status); } else { zero_fld_rec(&nn_t1f2_rec); nn_t1f2_rec.fldtype = I1; status = add_aux_fld(NULL, t1_id, NULL, t1f2_id, nn_ddir_id, nn_fileno, nn, &nn_t1f2_id, &nn_t1f2_rec); cBYE(status); } } /*-------------------------------------------------------*/ BYE: if ( Y != NULL ) { for ( int i = 0; i < nY; i++ ) { free_if_non_null(Y[i]); } free_if_non_null(Y); } rs_munmap(X, nX); rs_munmap(nn_X, nn_nX); rs_munmap(X1, nX1); rs_munmap(X2, nX2); rs_munmap(nn_X1, nn_nX1); rs_munmap(nn_X2, nn_nX2); rs_munmap(t2f2_X, n_t2f2_X); rs_munmap(nn_t2f2_X, nn_n_t2f2_X); return(status); }
void si_delete(/*@only@*/ sorted_intlist si) { assert(si != NULL); assert(si->q != NULL); q_delete(si->q); free(si); }