Debian Codegraph @

test/assets/cproc/6.11-int=2=

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_2 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 /* Size check, assert (length (list) == 2) */
52 if (_x.c != 2) {
53 Tcl_AppendResult (interp, "Expected a list of 2", NULL);
54 return TCL_ERROR;
55 }
56 _x.v = (int*) ((!_x.c) ? 0 : ckalloc (_x.c * sizeof (int)));
57 for (k = 0; k < _x.c; k++) {
58 if (_critcl_list_int_item (interp, el[k], &(_x.v[k])) != TCL_OK) {
59 ckfree ((char*) _x.v); /* Cleanup partial work */
60 return TCL_ERROR;
61 }
62 } }
63
64 /* Call - - -- --- ----- -------- */
65 c__aproc0(_x);
66
67 /* (Release: list_int_2 x) - - -- --- ----- -------- */
68 if (_x.c) { ckfree ((char*) _x.v); }
69
70 /* (void return) - - -- --- ----- -------- */
71 return TCL_OK;
72 }