/* ---------------------------------------------------------------------- */ #define ns__aproc0 "::aproc" #ifndef CRITCL_list_int #define CRITCL_list_int /* NOTE: Array 'v' is allocated on the heap. The argument // release code is used to free it after the worker // function returned. Depending on type and what is done // by the worker it may have to make copies of the data. */ typedef struct critcl_list_int { Tcl_Obj* o; /* Original list object, for pass-through cases */ Tcl_Size c; /* Element count */ int* v; /* Allocated array of the elements */ } critcl_list_int; static int _critcl_list_int_item (Tcl_Interp* interp, Tcl_Obj* src, int* dst) { { if (Tcl_GetIntFromObj(interp, src, dst) != TCL_OK) return TCL_ERROR; } return TCL_OK; } #endif /* CRITCL_list_int _________ */ static void c__aproc0(critcl_list_int x) { } static int tcl__aproc0(ClientData cd, Tcl_Interp *interp, Tcl_Size oc, Tcl_Obj *CONST ov[]) { critcl_list_int _x; if (oc != 2) { Tcl_WrongNumArgs(interp, 1, ov, "x"); return TCL_ERROR; } /* (list_int_any x) - - -- --- ----- -------- */ { int k; Tcl_Obj** el; if (Tcl_ListObjGetElements (interp, ov[1], /* OK tcl9 */ &(_x.c), &el) != TCL_OK) return TCL_ERROR; _x.o = ov[1]; _x.v = (int*) ((!_x.c) ? 0 : ckalloc (_x.c * sizeof (int))); for (k = 0; k < _x.c; k++) { if (_critcl_list_int_item (interp, el[k], &(_x.v[k])) != TCL_OK) { ckfree ((char*) _x.v); /* Cleanup partial work */ return TCL_ERROR; } } } /* Call - - -- --- ----- -------- */ c__aproc0(_x); /* (Release: list_int_any x) - - -- --- ----- -------- */ if (_x.c) { ckfree ((char*) _x.v); } /* (void return) - - -- --- ----- -------- */ return TCL_OK; }