summaryrefslogtreecommitdiffstats
path: root/generic/tclAlloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclAlloc.c')
-rw-r--r--generic/tclAlloc.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/generic/tclAlloc.c b/generic/tclAlloc.c
index 64df1a2..675e1a4 100644
--- a/generic/tclAlloc.c
+++ b/generic/tclAlloc.c
@@ -32,7 +32,7 @@
*/
#if defined(_MSC_VER) || defined(__MSVCRT__) || defined(__BORLANDC__)
-typedef size_t caddr_t;
+typedef unsigned long caddr_t;
#endif
/*
@@ -56,7 +56,7 @@ union overhead {
unsigned char magic1; /* other magic number */
#ifndef NDEBUG
unsigned short rmagic; /* range magic number */
- size_t size; /* actual block size */
+ unsigned long size; /* actual block size */
unsigned short unused2; /* padding to 8-byte align */
#endif
} ovu;
@@ -72,7 +72,7 @@ union overhead {
#define RMAGIC 0x5555 /* magic # on range info */
#ifndef NDEBUG
-#define RSLOP sizeof(unsigned short)
+#define RSLOP sizeof (unsigned short)
#else
#define RSLOP 0
#endif
@@ -133,7 +133,8 @@ static int allocInit = 0;
* a given block size.
*/
-static size_t numMallocs[NBUCKETS+1];
+static unsigned int numMallocs[NBUCKETS+1];
+#include <stdio.h>
#endif
#if !defined(NDEBUG)
@@ -148,7 +149,7 @@ static size_t numMallocs[NBUCKETS+1];
* Prototypes for functions used only in this file.
*/
-static void MoreCore(size_t bucket);
+static void MoreCore(int bucket);
/*
*-------------------------------------------------------------------------
@@ -254,7 +255,7 @@ TclpAlloc(
unsigned int numBytes) /* Number of bytes to allocate. */
{
register union overhead *overPtr;
- register size_t bucket;
+ register long bucket;
register unsigned amount;
struct block *bigBlockPtr = NULL;
@@ -385,12 +386,12 @@ TclpAlloc(
static void
MoreCore(
- size_t bucket) /* What bucket to allocate to. */
+ int bucket) /* What bucket to allocat to. */
{
register union overhead *overPtr;
- register size_t size; /* size of desired block */
- size_t amount; /* amount to allocate */
- size_t numBlocks; /* how many blocks we get */
+ register long size; /* size of desired block */
+ long amount; /* amount to allocate */
+ int numBlocks; /* how many blocks we get */
struct block *blockPtr;
/*
@@ -398,14 +399,14 @@ MoreCore(
* VAX, I think) or for a negative arg.
*/
- size = ((size_t)1) << (bucket + 3);
+ size = 1 << (bucket + 3);
ASSERT(size > 0);
amount = MAXMALLOC;
numBlocks = amount / size;
ASSERT(numBlocks*size == amount);
- blockPtr = (struct block *) TclpSysAlloc(
+ blockPtr = (struct block *) TclpSysAlloc((unsigned)
(sizeof(struct block) + amount), 1);
/* no more room! */
if (blockPtr == NULL) {
@@ -448,7 +449,7 @@ void
TclpFree(
char *oldPtr) /* Pointer to memory to free. */
{
- register size_t size;
+ register long size;
register union overhead *overPtr;
struct block *bigBlockPtr;
@@ -457,7 +458,7 @@ TclpFree(
}
Tcl_MutexLock(allocMutexPtr);
- overPtr = (union overhead *)((caddr_t)oldPtr - sizeof(union overhead));
+ overPtr = (union overhead *)((caddr_t)oldPtr - sizeof (union overhead));
ASSERT(overPtr->overMagic0 == MAGIC); /* make sure it was in use */
ASSERT(overPtr->overMagic1 == MAGIC);
@@ -518,7 +519,7 @@ TclpRealloc(
union overhead *overPtr;
struct block *bigBlockPtr;
int expensive;
- size_t maxSize;
+ unsigned long maxSize;
if (oldPtr == NULL) {
return TclpAlloc(numBytes);
@@ -526,7 +527,7 @@ TclpRealloc(
Tcl_MutexLock(allocMutexPtr);
- overPtr = (union overhead *)((caddr_t)oldPtr - sizeof(union overhead));
+ overPtr = (union overhead *)((caddr_t)oldPtr - sizeof (union overhead));
ASSERT(overPtr->overMagic0 == MAGIC); /* make sure it was in use */
ASSERT(overPtr->overMagic1 == MAGIC);
@@ -645,30 +646,30 @@ void
mstats(
char *s) /* Where to write info. */
{
- register unsigned int i, j;
+ register int i, j;
register union overhead *overPtr;
- size_t totalFree = 0, totalUsed = 0;
+ int totalFree = 0, totalUsed = 0;
Tcl_MutexLock(allocMutexPtr);
fprintf(stderr, "Memory allocation statistics %s\nTclpFree:\t", s);
for (i = 0; i < NBUCKETS; i++) {
for (j=0, overPtr=nextf[i]; overPtr; overPtr=overPtr->next, j++) {
- fprintf(stderr, " %u", j);
+ fprintf(stderr, " %d", j);
}
- totalFree += ((size_t)j) * (1 << (i + 3));
+ totalFree += j * (1 << (i + 3));
}
fprintf(stderr, "\nused:\t");
for (i = 0; i < NBUCKETS; i++) {
- fprintf(stderr, " %" TCL_LL_MODIFIER "d", (Tcl_WideInt)numMallocs[i]);
+ fprintf(stderr, " %d", numMallocs[i]);
totalUsed += numMallocs[i] * (1 << (i + 3));
}
- fprintf(stderr, "\n\tTotal small in use: %" TCL_LL_MODIFIER "d, total free: %" TCL_LL_MODIFIER "d\n",
- (Tcl_WideInt)totalUsed, (Tcl_WideInt)totalFree);
- fprintf(stderr, "\n\tNumber of big (>%d) blocks in use: %" TCL_LL_MODIFIER "d\n",
- MAXMALLOC, (Tcl_WideInt)numMallocs[NBUCKETS]);
+ fprintf(stderr, "\n\tTotal small in use: %d, total free: %d\n",
+ totalUsed, totalFree);
+ fprintf(stderr, "\n\tNumber of big (>%d) blocks in use: %d\n",
+ MAXMALLOC, numMallocs[NBUCKETS]);
Tcl_MutexUnlock(allocMutexPtr);
}
@@ -696,7 +697,7 @@ char *
TclpAlloc(
unsigned int numBytes) /* Number of bytes to allocate. */
{
- return (char *) malloc(numBytes);
+ return (char*) malloc(numBytes);
}
/*
@@ -744,7 +745,7 @@ TclpRealloc(
char *oldPtr, /* Pointer to alloced block. */
unsigned int numBytes) /* New size of memory. */
{
- return (char *) realloc(oldPtr, numBytes);
+ return (char*) realloc(oldPtr, numBytes);
}
#endif /* !USE_TCLALLOC */