51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
-
+
-
+
|
ERR_clear_error();
/* Validate arg count */
if (objc < 2 || objc > 3) {
Tcl_WrongNumArgs(interp, 1, objv, "?-private? length");
return TCL_ERROR;
} else if (objc == 3) {
int fn;
Tcl_Size fn;
if (Tcl_GetIndexFromObj(interp, objv[1], command_opts, "option", 0, &fn) != TCL_OK) {
return TCL_ERROR;
}
}
/* Get length */
if (Tcl_GetIntFromObj(interp, objv[objc - 1], &out_len) != TCL_OK) {
return TCL_ERROR;
}
if (out_len < 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad count \"%d\": must be integer >= 0", out_len));
return TCL_ERROR;
}
/* Allocate storage for result */
resultObj = Tcl_NewObj();
out_buf = Tcl_SetByteArrayLength(resultObj, out_len);
out_buf = Tcl_SetByteArrayLength(resultObj, (Tcl_Size) out_len);
if (resultObj == NULL || out_buf == NULL) {
Tcl_AppendResult(interp, "Memory allocation error", (char *) NULL);
Tcl_DecrRefCount(resultObj);
return TCL_ERROR;
}
/* Get random bytes */
|