X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fodr_util.c;fp=src%2Fodr_util.c;h=c28c586c96b62c01a7cd156b78a4a38e63408b40;hp=c50ac55b3a977df0bf816c9bdbc5dc12c0f7af0b;hb=be821514c869d68186361b5aab6bbfd1aa60e087;hpb=aa29dbf34d5bb3cbf5b26ee3adfbaf9f9b4f3c67 diff --git a/src/odr_util.c b/src/odr_util.c index c50ac55..c28c586 100644 --- a/src/odr_util.c +++ b/src/odr_util.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: odr_util.c,v 1.11 2007-04-12 13:52:57 adam Exp $ + * $Id: odr_util.c,v 1.12 2007-04-12 20:47:28 adam Exp $ */ /** * \file odr_util.c @@ -63,20 +63,13 @@ Odr_oid *odr_oiddup(ODR odr, const Odr_oid *o) Odr_oid *odr_getoidbystr_nmem(NMEM nmem, const char *str) { - int num = 1, i = 0; - const char *p = str; - Odr_oid *ret; + int oid[OID_SIZE]; + int *ret; - if (!isdigit(*(const unsigned char *) str)) + if (oid_dotstring_to_oid(str, oid)) return 0; - while ((p = strchr(p, '.'))) - num++, p++; - ret = (int *)nmem_malloc(nmem, sizeof(*ret)*(num + 1)); - p = str; - do - ret[i++] = atoi(p); - while ((p = strchr(p, '.')) && *++p); - ret[i] = -1; + ret = (int *)nmem_malloc(nmem, sizeof(*ret)*(oid_oidlen(oid) + 1)); + oid_oidcpy(ret, oid); return ret; }