static Z_ReferenceId *set_refid(ODR out)
{
- Z_ReferenceId *id;
if (!refid)
return 0;
- id = (Z_ReferenceId *) odr_malloc(out, sizeof(*id));
- id->len = strlen(refid);
- id->buf = (char *) odr_malloc(out, id->len);
- memcpy(id->buf, refid, id->len);
- return id;
+ return odr_create_Odr_oct(out, refid, strlen(refid));
}
/* INIT SERVICE ------------------------------- */
r->indirect_reference = 0;
r->descriptor = 0;
r->which = Z_External_single;
-
- r->u.single_ASN1_type = (Odr_oct *)
- odr_malloc(out, sizeof(*r->u.single_ASN1_type));
- r->u.single_ASN1_type->buf = (char *)
- odr_malloc(out, item_request_size);
- r->u.single_ASN1_type->len = item_request_size;
- memcpy(r->u.single_ASN1_type->buf, item_request_buf,
- item_request_size);
-
+ r->u.single_ASN1_type =
+ odr_create_Odr_oct(out, item_request_buf, item_request_size);
do_hex_dump(item_request_buf,item_request_size);
}
return r;
r->indirect_reference = 0;
r->descriptor = 0;
r->which = Z_External_single;
-
- r->u.single_ASN1_type = (Odr_oct *)
- odr_malloc(out, sizeof(*r->u.single_ASN1_type));
- r->u.single_ASN1_type->buf = (char *)
- odr_malloc(out, ill_request_size);
- r->u.single_ASN1_type->len = ill_request_size;
- 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); */
-/* printf("--- end of extenal\n"); */
-
+ r->u.single_ASN1_type = odr_create_Odr_oct(out, ill_request_buf,
+ ill_request_size);
}
return r;
}
notToKeep->elements[0] = (Z_IU0SuppliedRecords_elem *)
odr_malloc(out, sizeof(**notToKeep->elements));
notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
- if (recid)
- {
- notToKeep->elements[0]->u.opaque = (Odr_oct *)
- odr_malloc(out, sizeof(Odr_oct));
- notToKeep->elements[0]->u.opaque->buf = (char *) recid;
- notToKeep->elements[0]->u.opaque->len = strlen(recid);
- }
- else
- notToKeep->elements[0]->u.opaque = 0;
+ notToKeep->elements[0]->u.opaque = recid ?
+ odr_create_Odr_oct(out, recid, strlen(recid)) : 0;
notToKeep->elements[0]->supplementalId = 0;
notToKeep->elements[0]->correlationInfo = 0;
notToKeep->elements[0]->record = record_this;
notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *)
odr_malloc(out, sizeof(**notToKeep->elements));
notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
- if (recid)
- {
- notToKeep->elements[0]->u.opaque = (Odr_oct *)
- odr_malloc(out, sizeof(Odr_oct));
- notToKeep->elements[0]->u.opaque->buf = (char *) recid;
- notToKeep->elements[0]->u.opaque->len = strlen(recid);
- }
- else
- notToKeep->elements[0]->u.opaque = 0;
+ notToKeep->elements[0]->u.opaque = recid ?
+ odr_create_Odr_oct(out, recid, strlen(recid)) : 0;
notToKeep->elements[0]->supplementalId = 0;
notToKeep->elements[0]->correlationInfo = 0;
notToKeep->elements[0]->record = record_this;
return 0;
p->descriptor = 0;
p->indirect_reference = 0;
-
p->direct_reference = odr_oiddup(o, yaz_oid_negot_charset_id);
-
p->which = Z_External_octet;
- if (!(p->u.octet_aligned = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct))))
- return 0;
- if (!(p->u.octet_aligned->buf = (char *)odr_malloc(o, len)))
- return 0;
- p->u.octet_aligned->len = len;
- memcpy(p->u.octet_aligned->buf, buf, len);
-
+ p->u.octet_aligned =
+ odr_create_Odr_oct(o, buf, len);
return p;
}
Z_Term *z_Term_create(ODR o, int term_type, const char *buf, size_t len)
{
Z_Term *term = (Z_Term *)odr_malloc(o, sizeof(*term));
- Odr_oct *term_octet = (Odr_oct *)odr_malloc(o, sizeof(*term_octet));
- term_octet->buf = (char *)odr_malloc(o, 1 + len);
- memcpy(term_octet->buf, buf, len);
- term_octet->len = len;
- term_octet->buf[term_octet->len] = 0; /* null terminate */
-
switch (term_type)
{
case Z_Term_general:
term->which = Z_Term_general;
- term->u.general = term_octet;
+ term->u.general = odr_create_Odr_oct(o, buf, len);
break;
case Z_Term_characterString:
term->which = Z_Term_characterString;
- term->u.characterString = (char*) term_octet->buf;
- /* null terminated above */
+ term->u.characterString = odr_strdupn(o, buf, len);
break;
case Z_Term_numeric:
term->which = Z_Term_numeric;
- term->u.numeric = odr_intdup(o, odr_atoi((const char*) term_octet->buf));
+ term->u.numeric = odr_intdup(o, odr_atoi(odr_strdupn(o, buf, len)));
break;
case Z_Term_null:
term->which = Z_Term_null;
{
Z_Entry *e;
Z_TermInfo *t;
- Odr_oct *o;
tab[i] = e = (Z_Entry *)odr_malloc(assoc->encode, sizeof(*e));
if (bsrr->entries[i].occurrences >= 0)
t->term = (Z_Term *)
odr_malloc(assoc->encode, sizeof(*t->term));
t->term->which = Z_Term_general;
- t->term->u.general = o =
- (Odr_oct *)odr_malloc(assoc->encode, sizeof(Odr_oct));
- o->buf = (char *)
- odr_malloc(assoc->encode, o->len =
- strlen(bsrr->entries[i].term));
- memcpy(o->buf, bsrr->entries[i].term, o->len);
+ t->term->u.general =
+ odr_create_Odr_oct(assoc->encode,
+ bsrr->entries[i].term,
+ strlen(bsrr->entries[i].term));
yaz_log(YLOG_DEBUG, " term #%d: '%s' (" ODR_INT_PRINTF ")", i,
bsrr->entries[i].term, bsrr->entries[i].occurrences);
}
x->indirect_reference = 0;
x->direct_reference = odr_oiddup(odr, yaz_oid_userinfo_userinfo_1);
x->which = Z_External_octet;
- x->u.octet_aligned = (Odr_oct *) odr_malloc(odr, sizeof(Odr_oct));
- x->u.octet_aligned->buf = (char *) odr_malloc(odr, octet_len);
- memcpy(x->u.octet_aligned->buf, octet_buf, octet_len);
- x->u.octet_aligned->len = octet_len;
+ x->u.octet_aligned = odr_create_Odr_oct(odr, octet_buf, octet_len);
odr_destroy(encode);
npr->u.databaseRecord->indirect_reference = 0;
npr->u.databaseRecord->which = Z_External_octet;
- npr->u.databaseRecord->u.octet_aligned = (Odr_oct *)
- odr_malloc(c->odr_in, sizeof(Odr_oct));
- npr->u.databaseRecord->u.octet_aligned->buf =
- sru_rec->recordData_buf;
- npr->u.databaseRecord->u.octet_aligned->len =
- sru_rec->recordData_len;
+ npr->u.databaseRecord->u.octet_aligned =
+ odr_create_Odr_oct(c->odr_in,
+ sru_rec->recordData_buf,
+ sru_rec->recordData_len);
if (sru_rec->recordSchema
&& !strcmp(sru_rec->recordSchema,
"info:srw/schema/1/diagnostics-v1.1"))
rr->taskPackage->retentionTime = 0;
rr->taskPackage->permissions = 0;
rr->taskPackage->description = 0;
- rr->taskPackage->targetReference = (Odr_oct *)
- odr_malloc(rr->stream, sizeof(Odr_oct));
- rr->taskPackage->targetReference->buf =
- odr_strdup(rr->stream, "911");
- rr->taskPackage->targetReference->len =
- strlen((char *) (rr->taskPackage->targetReference->buf));
+ rr->taskPackage->targetReference =
+ odr_create_Odr_oct(rr->stream, "911", 3);
rr->taskPackage->creationDateTime = 0;
rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
rr->taskPackage->packageDiagnostics = 0;
rr->taskPackage->retentionTime = 0;
rr->taskPackage->permissions = 0;
rr->taskPackage->description = 0;
- rr->taskPackage->targetReference = (Odr_oct *)
- odr_malloc(rr->stream, sizeof(Odr_oct));
- rr->taskPackage->targetReference->buf =
- odr_strdup(rr->stream, "123");
- rr->taskPackage->targetReference->len =
- strlen((char *) (rr->taskPackage->targetReference->buf));
+ rr->taskPackage->targetReference =
+ odr_create_Odr_oct(rr->stream, "123", 3);
rr->taskPackage->creationDateTime = 0;
rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
rr->taskPackage->packageDiagnostics = 0;