Debian Codegraph @

test/assets/cproc-trace/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 critcl_trace_cmd_args (ns__aproc0, oc, ov);
39
40 if (oc != 2) {
41 Tcl_WrongNumArgs(interp, 1, ov, "x");
42 return critcl_trace_cmd_result (TCL_ERROR, interp);
43 }
44
45 /* (list_int_2 x) - - -- --- ----- -------- */
46 {
47 int k;
48 Tcl_Obj** el;
49 if (Tcl_ListObjGetElements (interp, ov[1], /* OK tcl9 */
50 &(_x.c), &el) != TCL_OK) return critcl_trace_cmd_result (TCL_ERROR, interp);
51 _x.o = ov[1];
52
53 /* Size check, assert (length (list) == 2) */
54 if (_x.c != 2) {
55 Tcl_AppendResult (interp, "Expected a list of 2", NULL);
56 return critcl_trace_cmd_result (TCL_ERROR, interp);
57 }
58 _x.v = (int*) ((!_x.c) ? 0 : ckalloc (_x.c * sizeof (int)));
59 for (k = 0; k < _x.c; k++) {
60 if (_critcl_list_int_item (interp, el[k], &(_x.v[k])) != TCL_OK) {
61 ckfree ((char*) _x.v); /* Cleanup partial work */
62 return critcl_trace_cmd_result (TCL_ERROR, interp);
63 }
64 } }
65
66 /* Call - - -- --- ----- -------- */
67 c__aproc0(_x);
68
69 /* (Release: list_int_2 x) - - -- --- ----- -------- */
70 if (_x.c) { ckfree ((char*) _x.v); }
71
72 /* (void return) - - -- --- ----- -------- */
73 return critcl_trace_cmd_result (TCL_OK, interp);
74 }