summaryrefslogtreecommitdiffstats
path: root/generic/tclCkalloc.c
diff options
context:
space:
mode:
authorericm <ericm>2000-09-14 18:42:27 (GMT)
committerericm <ericm>2000-09-14 18:42:27 (GMT)
commit9e68d5fcbb5c7e9d1e17dcaacab6688f786bcd10 (patch)
treede9d337513da3daa50909f5c0d11116e6ab9262e /generic/tclCkalloc.c
parent62db39876a0a1797a02f9ab37238f2d377295696 (diff)
downloadtcl-9e68d5fcbb5c7e9d1e17dcaacab6688f786bcd10.zip
tcl-9e68d5fcbb5c7e9d1e17dcaacab6688f786bcd10.tar.gz
tcl-9e68d5fcbb5c7e9d1e17dcaacab6688f786bcd10.tar.bz2
* doc/Alloc.3: Added entries for Tcl_AttemptAlloc, Tcl_AttempRealloc.
* doc/StringObj.3: Added entry for Tcl_AttemptSetObjLength. * generic/tclDecls.h: * generic/tclStubInit.c: Regen'ed stubs files from new tcl.decls. * generic/tcl.decls: Added stubs for the Tcl_Attempt* memory allocators and for Tcl_AttemptSetObjLength. * generic/tcl.h: Added #define's for attemptckalloc, attemptckrealloc, which map to the Tcl_Attempt* memory allocators. * generic/tclCkalloc.c: Added non-panic'ing versions of Tcl_Alloc, Tcl_Realloc, etc.; these are called Tcl_AttemptAlloc, Tcl_AttemptRealloc, etc. These are used by Tcl_AttemptSetObjLength and the string obj append functions. * generic/tclStringObj.c: Modified string growth algorithm to use doubling algorithm as long as possible, and only fall back when that fails. Added Tcl_AttemptSetObjLength, and modified AppendUnicodeToUnicodeRep, AppendUtfToUtfRep, and Tcl_AppendStringsToObjVA to support this.
Diffstat (limited to 'generic/tclCkalloc.c')
-rw-r--r--generic/tclCkalloc.c84
1 files changed, 83 insertions, 1 deletions
diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c
index a85a0fd..c0d79e4 100644
--- a/generic/tclCkalloc.c
+++ b/generic/tclCkalloc.c
@@ -13,7 +13,7 @@
*
* This code contributed by Karl Lehenbauer and Mark Diekhans
*
- * RCS: @(#) $Id: tclCkalloc.c,v 1.8 2000/04/27 01:47:01 ericm Exp $
+ * RCS: @(#) $Id: tclCkalloc.c,v 1.9 2000/09/14 18:42:30 ericm Exp $
*/
#include "tclInt.h"
@@ -593,6 +593,8 @@ Tcl_DbCkrealloc(ptr, size, file, line)
#undef Tcl_Alloc
#undef Tcl_Free
#undef Tcl_Realloc
+#undef Tcl_AttemptAlloc
+#undef Tcl_AttemptRealloc
char *
Tcl_Alloc(size)
@@ -601,6 +603,13 @@ Tcl_Alloc(size)
return Tcl_DbCkalloc(size, "unknown", 0);
}
+char *
+Tcl_AttemptAlloc(size)
+ unsigned int size;
+{
+ return Tcl_AttemptDbCkalloc(size, "unknown", 0);
+}
+
void
Tcl_Free(ptr)
char *ptr;
@@ -615,6 +624,13 @@ Tcl_Realloc(ptr, size)
{
return Tcl_DbCkrealloc(ptr, size, "unknown", 0);
}
+char *
+Tcl_AttemptRealloc(ptr, size)
+ char *ptr;
+ unsigned int size;
+{
+ return Tcl_AttemptDbCkrealloc(ptr, size, "unknown", 0);
+}
/*
*----------------------------------------------------------------------
@@ -875,6 +891,38 @@ Tcl_DbCkalloc(size, file, line)
}
return result;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tcl_AttemptAlloc --
+ * Interface to TclpAlloc when TCL_MEM_DEBUG is disabled. It does not
+ * check that memory was actually allocated.
+ *
+ *----------------------------------------------------------------------
+ */
+
+char *
+Tcl_AttemptAlloc (size)
+ unsigned int size;
+{
+ char *result;
+
+ result = TclpAlloc(size);
+ return result;
+}
+
+char *
+Tcl_AttemptDbCkalloc(size, file, line)
+ unsigned int size;
+ char *file;
+ int line;
+{
+ char *result;
+
+ result = (char *) TclpAlloc(size);
+ return result;
+}
/*
@@ -923,6 +971,40 @@ Tcl_DbCkrealloc(ptr, size, file, line)
/*
*----------------------------------------------------------------------
*
+ * Tcl_AttemptRealloc --
+ * Interface to TclpRealloc when TCL_MEM_DEBUG is disabled. It does
+ * not check that memory was actually allocated.
+ *
+ *----------------------------------------------------------------------
+ */
+
+char *
+Tcl_AttemptRealloc(ptr, size)
+ char *ptr;
+ unsigned int size;
+{
+ char *result;
+
+ result = TclpRealloc(ptr, size);
+ return result;
+}
+
+char *
+Tcl_AttemptDbCkrealloc(ptr, size, file, line)
+ char *ptr;
+ unsigned int size;
+ char *file;
+ int line;
+{
+ char *result;
+
+ result = (char *) TclpRealloc(ptr, size);
+ return result;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tcl_Free --
* Interface to TclpFree when TCL_MEM_DEBUG is disabled. Done here
* rather in the macro to keep some modules from being compiled with