-void objfreeir(Tcl_Obj *o) {
- if (o->typePtr && o->typePtr->freeIntRepProc)
- o->typePtr->freeIntRepProc(o);
-}
-
-static int hbytes_t_sfa(Tcl_Interp *ip, Tcl_Obj *o) {
- char *str, *ep, *os;
- Byte *startbytes, *bytes;
- int l;
- char cbuf[3];
-
- os= str= Tcl_GetStringFromObj(o,&l); assert(str);
- if (l & 1) return staticerr(ip, "hbytes: conversion from hex:"
- " odd length in hex");
-
- startbytes= bytes= l ? TALLOC(l*2) : 0;
- cbuf[2]= 0;
- while (l>0) {
- cbuf[0]= *str++;
- cbuf[1]= *str++;
- *bytes++= strtoul(cbuf,&ep,16);
- if (ep != cbuf+2) {
- TFREE(startbytes);
-fprintf(stderr,">%d|%s|%s<\n",l,os,cbuf);
- return staticerr(ip, "hbytes: conversion from hex:"
- " bad hex digit");
- }
- l -= 2;
- }
- objfreeir(o);