Debian Codegraph @

test/assets/cproc/6.8-==int

raw
1 /* ---------------------------------------------------------------------- */
2
3 #define ns__aproc0 "::aproc"
4 #ifndef CRITCL_list_int
5 #define CRITCL_list_int
6
7 /* NOTE: Array 'v' is allocated on the heap. The argument
8 // release code is used to free it after the worker
9 // function returned. Depending on type and what is done
10 // by the worker it may have to make copies of the data.
11 */
12
13 typedef struct critcl_list_int {
14 Tcl_Obj* o; /* Original list object, for pass-through cases */
15 Tcl_Size c; /* Element count */
16 int* v; /* Allocated array of the elements */
17 } critcl_list_int;
18
19 static int
20 _critcl_list_int_item (Tcl_Interp* interp, Tcl_Obj* src, int* dst) {
21 {
22 if (Tcl_GetIntFromObj(interp, src, dst) != TCL_OK) return TCL_ERROR; }
23 return TCL_OK;
24 }
25
26 #endif /* CRITCL_list_int _________ */
27
28 static void c__aproc0(critcl_list_int x)
29 {
30
31 }
32
33 static int
34 tcl__aproc0(ClientData cd, Tcl_Interp *interp, Tcl_Size oc, Tcl_Obj *CONST ov[])
35 {
36 critcl_list_int _x;
37
38 if (oc != 2) {
39 Tcl_WrongNumArgs(interp, 1, ov, "x");
40 return TCL_ERROR;
41 }
42
43 /* (list_int_any x) - - -- --- ----- -------- */
44 {
45 int k;
46 Tcl_Obj** el;
47 if (Tcl_ListObjGetElements (interp, ov[1], /* OK tcl9 */
48 &(_x.c), &el) != TCL_OK) return TCL_ERROR;
49 _x.o = ov[1];
50
51 _x.v = (int*) ((!_x.c) ? 0 : ckalloc (_x.c * sizeof (int)));
52 for (k = 0; k < _x.c; k++) {
53 if (_critcl_list_int_item (interp, el[k], &(_x.v[k])) != TCL_OK) {
54 ckfree ((char*) _x.v); /* Cleanup partial work */
55 return TCL_ERROR;
56 }
57 } }
58
59 /* Call - - -- --- ----- -------- */
60 c__aproc0(_x);
61
62 /* (Release: list_int_any x) - - -- --- ----- -------- */
63 if (_x.c) { ckfree ((char*) _x.v); }
64
65 /* (void return) - - -- --- ----- -------- */
66 return TCL_OK;
67 }