=================================================================== RCS file: /home/cvs/OpenXM/src/ox_toolkit/ox.c,v retrieving revision 1.21 retrieving revision 1.25 diff -u -p -r1.21 -r1.25 --- OpenXM/src/ox_toolkit/ox.c 2003/02/04 20:43:55 1.21 +++ OpenXM/src/ox_toolkit/ox.c 2003/06/02 10:25:56 1.25 @@ -1,5 +1,5 @@ /* -*- mode: C; coding: euc-japan -*- */ -/* $OpenXM: OpenXM/src/ox_toolkit/ox.c,v 1.20 2003/01/13 12:03:12 ohara Exp $ */ +/* $OpenXM: OpenXM/src/ox_toolkit/ox.c,v 1.24 2003/05/25 16:35:40 ohara Exp $ */ /* This module includes functions for sending/receiveng CMO's. @@ -29,14 +29,11 @@ static cmo_string* receive_cmo_string(OXFILE *ox static cmo_mathcap* receive_cmo_mathcap(OXFILE *oxfp); static cmo_list* receive_cmo_list(OXFILE *oxfp); static cmo_monomial32* receive_cmo_monomial32(OXFILE *oxfp); -static cmo_zz* receive_cmo_zz(OXFILE *oxfp); static cmo_zero* receive_cmo_zero(OXFILE *oxfp); static cmo_dms_generic* receive_cmo_dms_generic(OXFILE *oxfp); static cmo_ring_by_name* receive_cmo_ring_by_name(OXFILE *oxfp); static cmo_distributed_polynomial* receive_cmo_distributed_polynomial(OXFILE *oxfp); - static cmo_error2* receive_cmo_error2(OXFILE *oxfp); -static void receive_mpz(OXFILE *oxfp, mpz_ptr mpz); static int send_cmo_null(OXFILE *oxfp, cmo_null* c); static int send_cmo_int32(OXFILE *oxfp, cmo_int32* m); @@ -44,11 +41,14 @@ static int send_cmo_string(OXFILE *oxfp, cmo_ static int send_cmo_mathcap(OXFILE *oxfp, cmo_mathcap* c); static int send_cmo_list(OXFILE *oxfp, cmo_list* c); static int send_cmo_monomial32(OXFILE *oxfp, cmo_monomial32* c); -static int send_cmo_zz(OXFILE *oxfp, cmo_zz* c); static int send_cmo_error2(OXFILE *oxfp, cmo_error2* c); -static int send_mpz(OXFILE *oxfp, mpz_ptr mpz); static int send_cmo_distributed_polynomial(OXFILE *oxfp, cmo_distributed_polynomial* c); +static cmo_zz* receive_cmo_zz(OXFILE *oxfp); +static void receive_mpz(OXFILE *oxfp, mpz_ptr mpz); +static int send_cmo_zz(OXFILE *oxfp, cmo_zz* c); +static int send_mpz(OXFILE *oxfp, mpz_ptr mpz); + /* hook functions. (yet not implemented) */ static hook_t hook_before_send_cmo = NULL; static hook_t hook_after_send_cmo = NULL; @@ -142,7 +142,7 @@ static cmo_int32* receive_cmo_int32(OXFILE *oxfp) static cmo_string* receive_cmo_string(OXFILE *oxfp) { int len = receive_int32(oxfp); - char* s = malloc(len+1); + char* s = MALLOC(len+1); memset(s, '\0', len+1); if (len > 0) { oxf_read(s, 1, len, oxfp); @@ -231,8 +231,13 @@ static cmo_error2* receive_cmo_error2(OXFILE *oxfp) /* receive_cmo() is called after receive_ox_tag(). */ cmo* receive_cmo(OXFILE *oxfp) { - cmo* m; int tag = receive_int32(oxfp); + return receive_cmo_tag(oxfp, tag); +} + +cmo *receive_cmo_tag(OXFILE *oxfp, int tag) +{ + cmo* m; switch(tag) { case CMO_NULL: m = receive_cmo_null(oxfp); @@ -542,7 +547,7 @@ static int send_mpz(OXFILE *oxfp, mpz_ptr mpz) ox_data* new_ox_data(cmo* c) { - ox_data* m = malloc(sizeof(ox_data)); + ox_data* m = MALLOC(sizeof(ox_data)); m->tag = OX_DATA; m->cmo = c; return m; @@ -550,7 +555,7 @@ ox_data* new_ox_data(cmo* c) ox_command* new_ox_command(int sm_code) { - ox_command* m = malloc(sizeof(ox_command)); + ox_command* m = MALLOC(sizeof(ox_command)); m->tag = OX_COMMAND; m->command = sm_code; return m; @@ -558,7 +563,7 @@ ox_command* new_ox_command(int sm_code) ox_sync_ball* new_ox_sync_ball() { - ox_sync_ball *m = malloc(sizeof(ox_sync_ball)); + ox_sync_ball *m = MALLOC(sizeof(ox_sync_ball)); m->tag = OX_SYNC_BALL; return m; }