1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
-
+
|
/*
* tclBinary.c --
*
* This file contains the implementation of the "binary" Tcl built-in
* command and the Tcl binary data object.
*
* Copyright (c) 1997 by Sun Microsystems, Inc.
* Copyright (c) 1998-1999 by Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclBinary.c,v 1.13.4.34 2010/04/29 23:32:24 dgp Exp $
* RCS: @(#) $Id: tclBinary.c,v 1.13.4.35 2010/04/30 14:16:17 dgp Exp $
*/
#include "tclInt.h"
#include "tommath.h"
#include <math.h>
|
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
|
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
|
-
+
+
-
-
-
+
+
+
+
+
+
+
|
/*
* If we need to, resize the allocated space in the byte array.
*/
if (byteArrayPtr->used + (int)len > byteArrayPtr->allocated) {
unsigned int attempt, used = byteArrayPtr->used;
ByteArray *tmpByteArrayPtr;
ByteArray *tmpByteArrayPtr = NULL;
attempt = byteArrayPtr->allocated;
do {
attempt *= 2;
} while (attempt < used+len);
if (BYTEARRAY_SIZE(attempt) > BYTEARRAY_SIZE(used)) {
tmpByteArrayPtr = (ByteArray *)
attemptckrealloc((char *) byteArrayPtr,
BYTEARRAY_SIZE(attempt));
tmpByteArrayPtr = (ByteArray *)
attemptckrealloc((char *) byteArrayPtr,
BYTEARRAY_SIZE(attempt));
}
if (tmpByteArrayPtr == NULL) {
attempt = used + len;
if (BYTEARRAY_SIZE(attempt) < BYTEARRAY_SIZE(used)) {
Tcl_Panic("attempt to allocate a bigger buffer than we can handle");
}
tmpByteArrayPtr = (ByteArray *) ckrealloc((char *) byteArrayPtr,
BYTEARRAY_SIZE(attempt));
}
byteArrayPtr = tmpByteArrayPtr;
byteArrayPtr->allocated = attempt;
byteArrayPtr->used = used;
|
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
|
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
|
-
+
|
if (count == BINARY_NOCOUNT) {
/*
* Note that we are casting away the const-ness of objv, but
* this is safe since we aren't going to modify the array.
*/
listv = (Tcl_Obj**)(objv + arg);
listv = (Tcl_Obj **) (objv + arg);
listc = 1;
count = 1;
} else {
TclListObjGetElements(interp, objv[arg], &listc, &listv);
if (count == BINARY_ALL) {
count = listc;
}
|