From 28c5fe25e891098bcf5f18dfd0e3abe729dc340f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 11 Sep 2013 10:12:03 +0200 Subject: [PATCH] Goodbye to Odr_oct.size --- client/admin.c | 3 --- client/client.c | 21 --------------------- include/yaz/odr.h | 5 ----- src/ber_any.c | 3 --- src/ber_oct.c | 23 ----------------------- src/charneg.c | 3 --- src/odr_mem.c | 3 --- src/odr_oct.c | 18 ------------------ src/pquery.c | 3 --- src/prt-ext.c | 9 --------- src/seshigh.c | 3 --- src/sortspec.c | 3 --- src/zoom-sru.c | 4 ---- test/test_odr.c | 6 ------ util/yaz-illclient.c | 12 ------------ ztest/ztest.c | 8 -------- 16 files changed, 127 deletions(-) diff --git a/client/admin.c b/client/admin.c index c7fb4e6..de29207 100644 --- a/client/admin.c +++ b/client/admin.c @@ -238,9 +238,6 @@ int cmd_adm_import(const char *arg) rec->u.intermediateFragment->u.notExternallyTagged = oct; oct->len = status.st_size; -#if OCT_SIZE - oct->size = status.st_size; -#endif oct->buf = (char *) odr_malloc (out, oct->len); if (fread(oct->buf, 1, oct->len, inf) != (size_t) oct->len) { diff --git a/client/client.c b/client/client.c index e6dd25a..58f7006 100644 --- a/client/client.c +++ b/client/client.c @@ -323,9 +323,6 @@ static Z_ReferenceId *set_refid(ODR out) return 0; id = (Z_ReferenceId *) odr_malloc(out, sizeof(*id)); id->len = strlen(refid); -#if OCT_SIZE - id->size = id->len; -#endif id->buf = (char *) odr_malloc(out, id->len); memcpy(id->buf, refid, id->len); return id; @@ -1569,9 +1566,6 @@ static int send_Z3950_searchRequest(const char *arg) /* send a very big referenceid to test transport stack etc. */ memset(big, 'A', 2100); bigo.len = 2100; -#if OCT_SIZE - bigo.size = bigo.len; -#endif bigo.buf = big; req->referenceId = &bigo; } @@ -2141,9 +2135,6 @@ static Z_External *create_external_itemRequest(void) r->u.single_ASN1_type->buf = (char *) odr_malloc(out, item_request_size); r->u.single_ASN1_type->len = item_request_size; -#if OCT_SIZE - r->u.single_ASN1_type->size = item_request_size; -#endif memcpy(r->u.single_ASN1_type->buf, item_request_buf, item_request_size); @@ -2196,9 +2187,6 @@ static Z_External *create_external_ILL_APDU(void) r->u.single_ASN1_type->buf = (char *) odr_malloc(out, ill_request_size); r->u.single_ASN1_type->len = ill_request_size; -#if OCT_SIZE - r->u.single_ASN1_type->size = ill_request_size; -#endif memcpy(r->u.single_ASN1_type->buf, ill_request_buf, ill_request_size); /* printf("len = %d\n", ill_request_size); */ /* do_hex_dump(ill_request_buf,ill_request_size); */ @@ -2497,9 +2485,6 @@ static int send_Z3950_update(int version, int action_no, const char *recid, notToKeep->elements[0]->u.opaque = (Odr_oct *) odr_malloc(out, sizeof(Odr_oct)); notToKeep->elements[0]->u.opaque->buf = (char *) recid; -#if OCT_SIZE - notToKeep->elements[0]->u.opaque->size = strlen(recid); -#endif notToKeep->elements[0]->u.opaque->len = strlen(recid); } else @@ -2546,9 +2531,6 @@ static int send_Z3950_update(int version, int action_no, const char *recid, notToKeep->elements[0]->u.opaque = (Odr_oct *) odr_malloc(out, sizeof(Odr_oct)); notToKeep->elements[0]->u.opaque->buf = (char *) recid; -#if OCT_SIZE - notToKeep->elements[0]->u.opaque->size = strlen(recid); -#endif notToKeep->elements[0]->u.opaque->len = strlen(recid); } else @@ -3403,9 +3385,6 @@ static int send_Z3950_scanrequest(const char *set, const char *query, req->termListAndStartPoint->term->u.general->buf = odr_strdup(out, term); req->termListAndStartPoint->term->u.general->len = strlen(term); -#if OCT_SIZE - req->termListAndStartPoint->term->u.general->size = strlen(term); -#endif } } req->referenceId = set_refid(out); diff --git a/include/yaz/odr.h b/include/yaz/odr.h index 0d3cff1..865e4d4 100644 --- a/include/yaz/odr.h +++ b/include/yaz/odr.h @@ -96,15 +96,10 @@ typedef nmem_bool_t Odr_bool; #define ODR_ENCODE 1 #define ODR_PRINT 2 -#define OCT_SIZE 0 - typedef struct odr_oct { char *buf; int len; -#if OCT_SIZE - int size; -#endif } Odr_oct; typedef void Odr_null; diff --git a/src/ber_any.c b/src/ber_any.c index e167d42..be23946 100644 --- a/src/ber_any.c +++ b/src/ber_any.c @@ -33,9 +33,6 @@ int ber_any(ODR o, Odr_any **p) (*p)->buf = (char *)odr_malloc(o, res); memcpy((*p)->buf, o->bp, res); (*p)->len = res; -#if OCT_SIZE - (*p)->size = res; -#endif o->bp += res; return 1; case ODR_ENCODE: diff --git a/src/ber_oct.c b/src/ber_oct.c index d86e414..5a36482 100644 --- a/src/ber_oct.c +++ b/src/ber_oct.c @@ -23,9 +23,6 @@ int ber_octetstring(ODR o, Odr_oct *p, int cons) { int res, len; const char *base; -#if OCT_SIZE - unsigned char *c; -#endif switch (o->direction) { @@ -55,31 +52,11 @@ int ber_octetstring(ODR o, Odr_oct *p, int cons) odr_seterror(o, OOTHER, 16); return 0; } -#if OCT_SIZE - assert(p->size == 0); - assert(p->len == 0); - if (len + 1 > p->size - p->len) - { - c = (unsigned char *)odr_malloc(o, p->size += len + 1); - if (p->len) - memcpy(c, p->buf, p->len); - p->buf = c; - } - if (len) - memcpy(p->buf + p->len, o->bp, len); - p->len += len; - o->bp += len; - /* the final null is really not part of the buffer, but */ - /* it helps somes applications that assumes C strings */ - if (len) - p->buf[p->len] = '\0'; -#else p->len = len; p->buf = odr_malloc(o, len + 1); memcpy(p->buf, o->bp, len); p->buf[len] = '\0'; o->bp += len; -#endif return 1; case ODR_ENCODE: if ((res = ber_enclen(o, p->len, 5, 0)) < 0) diff --git a/src/charneg.c b/src/charneg.c index 4794d7c..b7e750c 100644 --- a/src/charneg.c +++ b/src/charneg.c @@ -37,9 +37,6 @@ static Z_External* z_ext_record2(ODR o, const char *buf) if (!(p->u.octet_aligned->buf = (char *)odr_malloc(o, len))) return 0; p->u.octet_aligned->len = len; -#if OCT_SIZE - p->u.octet_aligned->size = len; -#endif memcpy(p->u.octet_aligned->buf, buf, len); return p; diff --git a/src/odr_mem.c b/src/odr_mem.c index c102b16..33e2bfa 100644 --- a/src/odr_mem.c +++ b/src/odr_mem.c @@ -67,9 +67,6 @@ Odr_oct *odr_create_Odr_oct(ODR o, const char *buf, int sz) Odr_oct *p = (Odr_oct *) odr_malloc(o, sizeof(Odr_oct)); p->buf = (char *) odr_malloc(o, sz); memcpy(p->buf, buf, sz); -#if OCT_SIZE - p->size = sz; -#endif p->len = sz; return p; } diff --git a/src/odr_oct.c b/src/odr_oct.c index a64648a..101f0d2 100644 --- a/src/odr_oct.c +++ b/src/odr_oct.c @@ -45,9 +45,6 @@ int odr_octetstring(ODR o, Odr_oct **p, int opt, const char *name) if (o->direction == ODR_DECODE) { *p = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct)); -#if OCT_SIZE - (*p)->size= 0; -#endif (*p)->len = 0; (*p)->buf = 0; } @@ -88,15 +85,9 @@ int odr_cstring(ODR o, char **p, int opt, const char *name) { t->buf = *p; t->len = strlen(*p); -#if OCT_SIZE - t->size = t->len; -#endif } else { -#if OCT_SIZE - t->size= 0; -#endif t->len = 0; t->buf = 0; } @@ -167,24 +158,15 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name) return 0; } t->len = outbuf - (char*) t->buf; -#if OCT_SIZE - t->size = t->len; -#endif } if (!t->buf) { t->buf = *p; t->len = strlen(*p); -#if OCT_SIZE - t->size = t->len; -#endif } } else { -#if OCT_SIZE - t->size= 0; -#endif t->len = 0; t->buf = 0; } diff --git a/src/pquery.c b/src/pquery.c index f2c39e8..0de4d73 100644 --- a/src/pquery.c +++ b/src/pquery.c @@ -314,9 +314,6 @@ Z_Term *z_Term_create(ODR o, int term_type, const char *buf, size_t len) term_octet->buf = (char *)odr_malloc(o, 1 + len); memcpy(term_octet->buf, buf, len); term_octet->len = len; -#if OCT_SIZE - term_octet->size = len; -#endif term_octet->buf[term_octet->len] = 0; /* null terminate */ switch (term_type) diff --git a/src/prt-ext.c b/src/prt-ext.c index b41b6a9..2f904f1 100644 --- a/src/prt-ext.c +++ b/src/prt-ext.c @@ -317,9 +317,6 @@ Z_External *z_ext_record_oid_nmem(NMEM nmem, const Odr_oid *oid, thisext->u.sutrs = sutrs; sutrs->buf = (char *)nmem_malloc(nmem, len); sutrs->len = len; -#if OCT_SIZE - sutrs->size = len; -#endif memcpy(sutrs->buf, buf, len); } else @@ -333,9 +330,6 @@ Z_External *z_ext_record_oid_nmem(NMEM nmem, const Odr_oid *oid, return 0; memcpy(thisext->u.octet_aligned->buf, buf, len); thisext->u.octet_aligned->len = len; -#if OCT_SIZE - thisext->u.octet_aligned->size = len; -#endif } return thisext; } @@ -367,9 +361,6 @@ Z_External *z_ext_record_oid_any(ODR o, const Odr_oid *oid, return 0; memcpy(thisext->u.single_ASN1_type->buf, buf, len); thisext->u.single_ASN1_type->len = len; -#if OCT_SIZE - thisext->u.single_ASN1_type->size = len; -#endif return thisext; } diff --git a/src/seshigh.c b/src/seshigh.c index 898af56..b900a59 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -3130,9 +3130,6 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb) o->buf = (char *) odr_malloc(assoc->encode, o->len = strlen(bsrr->entries[i].term)); -#if OCT_SIZE - o->size = o->len; -#endif memcpy(o->buf, bsrr->entries[i].term, o->len); yaz_log(YLOG_DEBUG, " term #%d: '%s' (" ODR_INT_PRINTF ")", i, bsrr->entries[i].term, bsrr->entries[i].occurrences); diff --git a/src/sortspec.c b/src/sortspec.c index 1a24be7..6cae7d8 100644 --- a/src/sortspec.c +++ b/src/sortspec.c @@ -121,9 +121,6 @@ Z_SortKeySpecList *yaz_sort_spec(ODR out, const char *arg) odr_malloc(out, sizeof(Odr_oct)); i++; sks->u.missingValueData->len = strlen(sort_flags+i); -#if OCT_SIZE - sks->u.missingValueData->size = sks->u.missingValueData->len; -#endif sks->u.missingValueData->buf = odr_strdup(out, sort_flags+i); i += strlen(sort_flags+i) - 1; break; diff --git a/src/zoom-sru.c b/src/zoom-sru.c index bdfe175..43f05f8 100644 --- a/src/zoom-sru.c +++ b/src/zoom-sru.c @@ -335,10 +335,6 @@ static zoom_ret handle_srw_response(ZOOM_connection c, sru_rec->recordData_buf; npr->u.databaseRecord->u.octet_aligned->len = sru_rec->recordData_len; -#if OCT_SIZE - npr->u.databaseRecord->u.octet_aligned->size = - sru_rec->recordData_len; -#endif if (sru_rec->recordSchema && !strcmp(sru_rec->recordSchema, "info:srw/schema/1/diagnostics-v1.1")) diff --git a/test/test_odr.c b/test/test_odr.c index 65e2ed1..1ff12ed 100644 --- a/test/test_odr.c +++ b/test/test_odr.c @@ -27,9 +27,6 @@ void tst_MySequence1(ODR encode, ODR decode) s->second = (Odr_oct *) odr_malloc(encode, sizeof(*s->second)); s->second->buf = (char *) "hello"; s->second->len = 5; -#if OCT_SIZE - s->second->size = 0; -#endif s->third = odr_booldup(encode, 1); s->fourth = odr_nullval(); s->fifth = odr_intdup(encode, YC_MySequence_enum1); @@ -84,9 +81,6 @@ void tst_MySequence2(ODR encode, ODR decode) s->second = (Odr_oct *) odr_malloc(encode, sizeof(*s->second)); s->second->buf = (char *) "hello"; s->second->len = 5; -#if OCT_SIZE - s->second->size = 0; -#endif s->third = odr_booldup(encode, 1); s->fourth = odr_nullval(); s->fifth = odr_intdup(encode, YC_MySequence_enum1); diff --git a/util/yaz-illclient.c b/util/yaz-illclient.c index b6dd6be..c0383cb 100644 --- a/util/yaz-illclient.c +++ b/util/yaz-illclient.c @@ -367,9 +367,6 @@ ILL_Extension *makepromptextension(struct prog_args *args, ODR odr) { ext->u.single_ASN1_type->buf= (char *) odr_malloc(odr, siz); memcpy(ext->u.single_ASN1_type->buf,buf, siz ); ext->u.single_ASN1_type->len = siz; -#if OCT_SIZE - ext->u.single_ASN1_type->size = siz; -#endif odr_reset(odr_ext); odr_reset(odr_prt); /*!*/ @@ -386,9 +383,6 @@ ILL_Extension *makepromptextension(struct prog_args *args, ODR odr) { e->item->buf= (char *) odr_malloc(odr, siz); memcpy(e->item->buf,buf, siz ); e->item->len = siz; -#if OCT_SIZE - e->item->size = siz; -#endif odr_destroy(odr_prt); odr_destroy(odr_ext); @@ -432,9 +426,6 @@ ILL_Extension *makeoclcextension(struct prog_args *args, ODR odr) { ext->u.single_ASN1_type->buf = (char *) odr_malloc(odr, siz); memcpy(ext->u.single_ASN1_type->buf,buf, siz ); ext->u.single_ASN1_type->len = siz; -#if OCT_SIZE - ext->u.single_ASN1_type->size = siz; -#endif odr_reset(odr_ext); odr_reset(odr_prt); /*!*/ @@ -451,9 +442,6 @@ ILL_Extension *makeoclcextension(struct prog_args *args, ODR odr) { e->item->buf= (char *) odr_malloc(odr, siz); memcpy(e->item->buf, buf, siz); e->item->len = siz; -#if OCT_SIZE - e->item->size = siz; -#endif odr_destroy(odr_prt); odr_destroy(odr_ext); diff --git a/ztest/ztest.c b/ztest/ztest.c index d1dbeed..14e374f 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -594,10 +594,6 @@ int ztest_esrequest(void *handle, bend_esrequest_rr *rr) odr_strdup(rr->stream, "911"); rr->taskPackage->targetReference->len = strlen((char *) (rr->taskPackage->targetReference->buf)); -#if OCT_SIZE - rr->taskPackage->targetReference->size = - strlen((char *) (rr->taskPackage->targetReference->buf)); -#endif rr->taskPackage->creationDateTime = 0; rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0); rr->taskPackage->packageDiagnostics = 0; @@ -698,10 +694,6 @@ int ztest_esrequest(void *handle, bend_esrequest_rr *rr) odr_strdup(rr->stream, "123"); rr->taskPackage->targetReference->len = strlen((char *) (rr->taskPackage->targetReference->buf)); -#if OCT_SIZE - rr->taskPackage->targetReference->size = - rr->taskPackage->targetReference->len; -#endif rr->taskPackage->creationDateTime = 0; rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0); rr->taskPackage->packageDiagnostics = 0; -- 1.7.10.4