summaryrefslogtreecommitdiffstats
path: root/generic/tclCkalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclCkalloc.c')
-rw-r--r--generic/tclCkalloc.c166
1 files changed, 58 insertions, 108 deletions
diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c
index 10bd1cb..f5a2340 100644
--- a/generic/tclCkalloc.c
+++ b/generic/tclCkalloc.c
@@ -20,9 +20,7 @@
#define FALSE 0
#define TRUE 1
-#undef Tcl_Alloc
#undef Tcl_Free
-#undef Tcl_Realloc
#undef Tcl_AttemptAlloc
#undef Tcl_AttemptRealloc
@@ -391,9 +389,9 @@ Tcl_DumpActiveMemory(
*----------------------------------------------------------------------
*/
-char *
+void *
Tcl_DbCkalloc(
- unsigned int size,
+ size_t size,
const char *file,
int line)
{
@@ -411,7 +409,7 @@ Tcl_DbCkalloc(
if (result == NULL) {
fflush(stdout);
TclDumpMemoryInfo((ClientData) stderr, 0);
- Tcl_Panic("unable to alloc %u bytes, %s line %d", size, file, line);
+ Tcl_Panic("unable to alloc %" TCL_LL_MODIFIER "d bytes, %s line %d", (Tcl_WideInt)size, file, line);
}
/*
@@ -457,8 +455,8 @@ Tcl_DbCkalloc(
}
if (alloc_tracing) {
- fprintf(stderr,"ckalloc %p %u %s %d\n",
- result->body, size, file, line);
+ fprintf(stderr,"ckalloc %p %" TCL_LL_MODIFIER "d %s %d\n",
+ result->body, (Tcl_WideInt)size, file, line);
}
if (break_on_malloc && (total_mallocs >= break_on_malloc)) {
@@ -481,9 +479,9 @@ Tcl_DbCkalloc(
return result->body;
}
-char *
+void *
Tcl_AttemptDbCkalloc(
- unsigned int size,
+ size_t size,
const char *file,
int line)
{
@@ -546,8 +544,8 @@ Tcl_AttemptDbCkalloc(
}
if (alloc_tracing) {
- fprintf(stderr,"ckalloc %p %u %s %d\n",
- result->body, size, file, line);
+ fprintf(stderr,"ckalloc %p %" TCL_LL_MODIFIER "d %s %d\n",
+ result->body, (Tcl_WideInt)size, file, line);
}
if (break_on_malloc && (total_mallocs >= break_on_malloc)) {
@@ -590,7 +588,7 @@ Tcl_AttemptDbCkalloc(
void
Tcl_DbCkfree(
- char *ptr,
+ void *ptr,
const char *file,
int line)
{
@@ -665,10 +663,10 @@ Tcl_DbCkfree(
*--------------------------------------------------------------------
*/
-char *
+void *
Tcl_DbCkrealloc(
- char *ptr,
- unsigned int size,
+ void *ptr,
+ size_t size,
const char *file,
int line)
{
@@ -696,10 +694,10 @@ Tcl_DbCkrealloc(
return newPtr;
}
-char *
+void *
Tcl_AttemptDbCkrealloc(
- char *ptr,
- unsigned int size,
+ void *ptr,
+ size_t size,
const char *file,
int line)
{
@@ -734,59 +732,6 @@ Tcl_AttemptDbCkrealloc(
/*
*----------------------------------------------------------------------
*
- * Tcl_Alloc, et al. --
- *
- * These functions are defined in terms of the debugging versions when
- * TCL_MEM_DEBUG is set.
- *
- * Results:
- * Same as the debug versions.
- *
- * Side effects:
- * Same as the debug versions.
- *
- *----------------------------------------------------------------------
- */
-
-char *
-Tcl_Alloc(
- unsigned int size)
-{
- return Tcl_DbCkalloc(size, "unknown", 0);
-}
-
-char *
-Tcl_AttemptAlloc(
- unsigned int size)
-{
- return Tcl_AttemptDbCkalloc(size, "unknown", 0);
-}
-
-void
-Tcl_Free(
- char *ptr)
-{
- Tcl_DbCkfree(ptr, "unknown", 0);
-}
-
-char *
-Tcl_Realloc(
- char *ptr,
- unsigned int size)
-{
- return Tcl_DbCkrealloc(ptr, size, "unknown", 0);
-}
-char *
-Tcl_AttemptRealloc(
- char *ptr,
- unsigned int size)
-{
- return Tcl_AttemptDbCkrealloc(ptr, size, "unknown", 0);
-}
-
-/*
- *----------------------------------------------------------------------
- *
* MemoryCmd --
*
* Implements the Tcl "memory" command, which provides Tcl-level control
@@ -1052,11 +997,12 @@ Tcl_InitMemory(
*----------------------------------------------------------------------
*/
-char *
+#undef Tcl_Alloc
+void *
Tcl_Alloc(
- unsigned int size)
+ size_t size)
{
- char *result;
+ void *result;
result = TclpAlloc(size);
@@ -1071,24 +1017,25 @@ Tcl_Alloc(
*/
if ((result == NULL) && size) {
- Tcl_Panic("unable to alloc %u bytes", size);
+ Tcl_Panic("unable to alloc %" TCL_LL_MODIFIER "u bytes", (Tcl_WideInt)size);
}
return result;
}
-char *
+void *
Tcl_DbCkalloc(
- unsigned int size,
+ size_t size,
const char *file,
int line)
{
- char *result;
+ void *result;
- result = (char *) TclpAlloc(size);
+ result = TclpAlloc(size);
if ((result == NULL) && size) {
fflush(stdout);
- Tcl_Panic("unable to alloc %u bytes, %s line %d", size, file, line);
+ Tcl_Panic("unable to alloc %" TCL_LL_MODIFIER "u bytes, %s line %d",
+ (Tcl_WideInt)size, file, line);
}
return result;
}
@@ -1104,25 +1051,25 @@ Tcl_DbCkalloc(
*----------------------------------------------------------------------
*/
-char *
+void *
Tcl_AttemptAlloc(
- unsigned int size)
+ size_t size)
{
- char *result;
+ void *result;
result = TclpAlloc(size);
return result;
}
-char *
+void *
Tcl_AttemptDbCkalloc(
- unsigned int size,
+ size_t size,
const char *file,
int line)
{
- char *result;
+ void *result;
- result = (char *) TclpAlloc(size);
+ result = TclpAlloc(size);
return result;
}
@@ -1137,35 +1084,37 @@ Tcl_AttemptDbCkalloc(
*----------------------------------------------------------------------
*/
-char *
+#undef Tcl_Realloc
+void *
Tcl_Realloc(
- char *ptr,
- unsigned int size)
+ void *ptr,
+ size_t size)
{
char *result;
result = TclpRealloc(ptr, size);
if ((result == NULL) && size) {
- Tcl_Panic("unable to realloc %u bytes", size);
+ Tcl_Panic("unable to realloc %" TCL_LL_MODIFIER "u bytes", (Tcl_WideInt)size);
}
return result;
}
-char *
+void *
Tcl_DbCkrealloc(
- char *ptr,
- unsigned int size,
+ void *ptr,
+ size_t size,
const char *file,
int line)
{
- char *result;
+ void *result;
- result = (char *) TclpRealloc(ptr, size);
+ result = TclpRealloc(ptr, size);
if ((result == NULL) && size) {
fflush(stdout);
- Tcl_Panic("unable to realloc %u bytes, %s line %d", size, file, line);
+ Tcl_Panic("unable to realloc %" TCL_LL_MODIFIER "u bytes, %s line %d",
+ (Tcl_WideInt)size, file, line);
}
return result;
}
@@ -1181,27 +1130,27 @@ Tcl_DbCkrealloc(
*----------------------------------------------------------------------
*/
-char *
+void *
Tcl_AttemptRealloc(
- char *ptr,
- unsigned int size)
+ void *ptr,
+ size_t size)
{
- char *result;
+ void *result;
result = TclpRealloc(ptr, size);
return result;
}
-char *
+void *
Tcl_AttemptDbCkrealloc(
- char *ptr,
- unsigned int size,
+ void *ptr,
+ size_t size,
const char *file,
int line)
{
- char *result;
+ void *result;
- result = (char *) TclpRealloc(ptr, size);
+ result = TclpRealloc(ptr, size);
return result;
}
@@ -1217,16 +1166,17 @@ Tcl_AttemptDbCkrealloc(
*----------------------------------------------------------------------
*/
+#undef Tcl_Free
void
Tcl_Free(
- char *ptr)
+ void *ptr)
{
TclpFree(ptr);
}
void
Tcl_DbCkfree(
- char *ptr,
+ void *ptr,
const char *file,
int line)
{