int rc, sockix;
DgramSocket *sock;
- rc= Tcl_ConvertToType(ip,o,&sockid_type);
+ rc= Tcl_ConvertToType(ip,o,&dgramsockid_type);
if (rc) return rc;
sockix= o->internalRep.longValue;
o= Tcl_NewObj();
Tcl_InvalidateStringRep(o);
o->internalRep.longValue= val->ix;
- o->typePtr= &sockid_type;
+ o->typePtr= &dgramsockid_type;
return o;
}
}
static void sockid_t_ustr(Tcl_Obj *o) {
- char buf[100];
- int l;
+ char buf[75];
- snprintf(buf,sizeof(buf),"dgramsock%d", (int)o->internalRep.longValue);
- l= o->length= strlen(buf);
- o->bytes= TALLOC(l+1);
- strcpy(o->bytes, buf);
+ snprintf(buf,sizeof(buf), "%d", (int)o->internalRep.longValue);
+ obj_updatestr_vstringls(o,
+ "dgramsock",9,
+ buf, strlen(buf),
+ (char*)0);
}
static int sockid_t_sfa(Tcl_Interp *ip, Tcl_Obj *o) {
errno=0; ul=strtoul(str+9,&ep,10);
if (errno || *ep) return staticerr(ip,"bad dgram socket id number");
if (ul > INT_MAX) return staticerr(ip,"out of range dgram socket id");
+
+ objfreeir(o);
o->internalRep.longValue= ul;
+ o->typePtr= &dgramsockid_type;
return TCL_OK;
}
-Tcl_ObjType sockid_type = {
- "sockid-nearly",
+Tcl_ObjType dgramsockid_type = {
+ "dgramsockid",
sockid_t_free, sockid_t_dup, sockid_t_ustr, sockid_t_sfa
};