chiark / gitweb /
idtable better documented and sorted
[chiark-tcl.git] / base / idtable.c
index c2f3aaa32f0dee504704dba14c182870c29bddf1..f64a1013bc6a15581e4853a0e35ecc0a0d6a47c2 100644 (file)
@@ -1,13 +1,5 @@
 /*
  */
-/*
- * dgram-socket create <local>                        => <sockid>
- * dgram-socket close <sockid>
- * dgram-socket transmit <sockid> <data> <remote>
- * dgram-socket on-receive <sockid> [<script>]
- *    calls, effectively,  eval <script> [list <data> <remote-addr> <socket>]
- *    if script not supplied, cancel
- */
 
 #include "tables.h"
 #include "hbytes.h"
@@ -45,6 +37,16 @@ int tabledataid_parse(Tcl_Interp *ip, Tcl_Obj *o, IdDataTable *tab) {
   return TCL_OK;
 }
 
+void tabledataid_disposing(void *val, IdDataTable *tab) {
+  int ix;
+
+  ix= *(int*)val;
+  if (ix==-1) return;
+  assert(tab->a[ix] == val);
+  tab->a[ix]= 0;
+  *(int*)val= -1;
+}
+
 int pat_iddata(Tcl_Interp *ip, Tcl_Obj *o, void **rv, IdDataTable *tab) {
   int rc, ix;
   void *r;
@@ -110,7 +112,7 @@ static void tabledataid_nt_ustr(Tcl_Obj *o) {
   char buf[75];
   const char *prefix;
 
-  prefix= o->internalRep.twoPtrValue.ptr2;
+  prefix= ((IdDataTable*)o->internalRep.twoPtrValue.ptr1)->prefix;
   snprintf(buf,sizeof(buf), "%lu",
           *(unsigned long*)o->internalRep.twoPtrValue.ptr2);
   obj_updatestr_vstringls(o,
@@ -119,7 +121,7 @@ static void tabledataid_nt_ustr(Tcl_Obj *o) {
                          (char*)0);
 }
 
-Tcl_ObjType tabledataid_ntype = {
+Tcl_ObjType tabledataid_nearlytype = {
   "tabledataid",
   tabledataid_nt_free, tabledataid_nt_dup,
   tabledataid_nt_ustr, tabledataid_nt_sfa