aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-01-18 03:26:07 +0000
committerChristopher Faylor <me@cgf.cx>2003-01-18 03:26:07 +0000
commit4c6a3e500e88196170c1938bd174d4cdb97e7a6d (patch)
tree1d5cf60b961aefb87b4453babf941b5863162d56
parente9152439113f89322368774977e52f339d88f382 (diff)
downloadnewlib-4c6a3e500e88196170c1938bd174d4cdb97e7a6d.zip
newlib-4c6a3e500e88196170c1938bd174d4cdb97e7a6d.tar.gz
newlib-4c6a3e500e88196170c1938bd174d4cdb97e7a6d.tar.bz2
* cygheap.cc: Change most 'int's to 'unsigned's.
(_cmalloc): Only check for size of malloced region when calculating budget. Add overhead when performing the sbrk. Previous change broke _crealloc.
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/cygheap.cc20
2 files changed, 16 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 19c0779..2d70f35 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,12 @@
2003-01-17 Christopher Faylor <cgf@redhat.com>
+ * cygheap.cc: Change most 'int's to 'unsigned's.
+ (_cmalloc): Only check for size of malloced region when calculating
+ budget. Add overhead when performing the sbrk. Previous change broke
+ _crealloc.
+
+2003-01-17 Christopher Faylor <cgf@redhat.com>
+
* dcrt0.cc (initialize_env): Use colon for CYGWIN_DEBUG separator.
* grp.cc: Change most statics to NO_COPY throughout.
* passwd.cc: Ditto.
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index e224ca8..7fdb87a 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -38,7 +38,7 @@ struct cygheap_entry
#define NBUCKETS (sizeof (cygheap->buckets) / sizeof (cygheap->buckets[0]))
#define N0 ((_cmalloc_entry *) NULL)
-#define to_cmalloc(s) ((_cmalloc_entry *) (((char *) (s)) - (int) (N0->data)))
+#define to_cmalloc(s) ((_cmalloc_entry *) (((char *) (s)) - (unsigned) (N0->data)))
#define CFMAP_OPTIONS (SEC_RESERVE | PAGE_READWRITE)
#define MVMAP_OPTIONS (FILE_MAP_WRITE)
@@ -208,18 +208,17 @@ cygheap_init ()
/* Copyright (C) 1997, 2000 DJ Delorie */
-static void *_cmalloc (int size) __attribute ((regparm(1)));
-static void *__stdcall _crealloc (void *ptr, int size) __attribute ((regparm(2)));
+static void *_cmalloc (unsigned size) __attribute ((regparm(1)));
+static void *__stdcall _crealloc (void *ptr, unsigned size) __attribute ((regparm(2)));
static void *__stdcall
-_cmalloc (int size)
+_cmalloc (unsigned size)
{
_cmalloc_entry *rvc;
unsigned b, sz;
/* Calculate "bit bucket" and size as a power of two. */
- for (b = 3, sz = 8; sz && sz < (size + sizeof (_cmalloc_entry));
- b++, sz <<= 1)
+ for (b = 3, sz = 8; sz && sz < size; b++, sz <<= 1)
continue;
cygheap_protect->acquire ();
@@ -231,7 +230,7 @@ _cmalloc (int size)
}
else
{
- rvc = (_cmalloc_entry *) _csbrk (sz);
+ rvc = (_cmalloc_entry *) _csbrk (sz + sizeof (_cmalloc_entry));
if (!rvc)
{
cygheap_protect->release ();
@@ -257,16 +256,15 @@ _cfree (void *ptr)
cygheap_protect->release ();
}
-static void *__stdcall _crealloc (void *ptr, int size) __attribute__((regparm(2)));
static void *__stdcall
-_crealloc (void *ptr, int size)
+_crealloc (void *ptr, unsigned size)
{
void *newptr;
if (ptr == NULL)
newptr = _cmalloc (size);
else
{
- int oldsize = 1 << to_cmalloc (ptr)->b;
+ unsigned oldsize = 1 << to_cmalloc (ptr)->b;
if (size <= oldsize)
return ptr;
newptr = _cmalloc (size);
@@ -284,7 +282,7 @@ _crealloc (void *ptr, int size)
#define tocygheap(s) ((cygheap_entry *) (((char *) (s)) - (int) (N->data)))
inline static void *
-creturn (cygheap_types x, cygheap_entry * c, int len)
+creturn (cygheap_types x, cygheap_entry * c, unsigned len)
{
if (!c)
{