* 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.
This commit is contained in:
		| @@ -1,3 +1,10 @@ | |||||||
|  | 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> | 2003-01-17  Christopher Faylor  <cgf@redhat.com> | ||||||
|  |  | ||||||
| 	* dcrt0.cc (initialize_env): Use colon for CYGWIN_DEBUG separator. | 	* dcrt0.cc (initialize_env): Use colon for CYGWIN_DEBUG separator. | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ struct cygheap_entry | |||||||
|  |  | ||||||
| #define NBUCKETS (sizeof (cygheap->buckets) / sizeof (cygheap->buckets[0])) | #define NBUCKETS (sizeof (cygheap->buckets) / sizeof (cygheap->buckets[0])) | ||||||
| #define N0 ((_cmalloc_entry *) NULL) | #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 CFMAP_OPTIONS (SEC_RESERVE | PAGE_READWRITE) | ||||||
| #define MVMAP_OPTIONS (FILE_MAP_WRITE) | #define MVMAP_OPTIONS (FILE_MAP_WRITE) | ||||||
| @@ -208,18 +208,17 @@ cygheap_init () | |||||||
|  |  | ||||||
| /* Copyright (C) 1997, 2000 DJ Delorie */ | /* Copyright (C) 1997, 2000 DJ Delorie */ | ||||||
|  |  | ||||||
| static void *_cmalloc (int size) __attribute ((regparm(1))); | static void *_cmalloc (unsigned size) __attribute ((regparm(1))); | ||||||
| static void *__stdcall _crealloc (void *ptr, int size) __attribute ((regparm(2))); | static void *__stdcall _crealloc (void *ptr, unsigned size) __attribute ((regparm(2))); | ||||||
|  |  | ||||||
| static void *__stdcall | static void *__stdcall | ||||||
| _cmalloc (int size) | _cmalloc (unsigned size) | ||||||
| { | { | ||||||
|   _cmalloc_entry *rvc; |   _cmalloc_entry *rvc; | ||||||
|   unsigned b, sz; |   unsigned b, sz; | ||||||
|  |  | ||||||
|   /* Calculate "bit bucket" and size as a power of two. */ |   /* Calculate "bit bucket" and size as a power of two. */ | ||||||
|   for (b = 3, sz = 8; sz && sz < (size + sizeof (_cmalloc_entry)); |   for (b = 3, sz = 8; sz && sz < size; b++, sz <<= 1) | ||||||
|        b++, sz <<= 1) |  | ||||||
|     continue; |     continue; | ||||||
|  |  | ||||||
|   cygheap_protect->acquire (); |   cygheap_protect->acquire (); | ||||||
| @@ -231,7 +230,7 @@ _cmalloc (int size) | |||||||
|     } |     } | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|       rvc = (_cmalloc_entry *) _csbrk (sz); |       rvc = (_cmalloc_entry *) _csbrk (sz + sizeof (_cmalloc_entry)); | ||||||
|       if (!rvc) |       if (!rvc) | ||||||
| 	{ | 	{ | ||||||
| 	  cygheap_protect->release (); | 	  cygheap_protect->release (); | ||||||
| @@ -257,16 +256,15 @@ _cfree (void *ptr) | |||||||
|   cygheap_protect->release (); |   cygheap_protect->release (); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void *__stdcall _crealloc (void *ptr, int size) __attribute__((regparm(2))); |  | ||||||
| static void *__stdcall | static void *__stdcall | ||||||
| _crealloc (void *ptr, int size) | _crealloc (void *ptr, unsigned size) | ||||||
| { | { | ||||||
|   void *newptr; |   void *newptr; | ||||||
|   if (ptr == NULL) |   if (ptr == NULL) | ||||||
|     newptr = _cmalloc (size); |     newptr = _cmalloc (size); | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
|       int oldsize = 1 << to_cmalloc (ptr)->b; |       unsigned oldsize = 1 << to_cmalloc (ptr)->b; | ||||||
|       if (size <= oldsize) |       if (size <= oldsize) | ||||||
| 	return ptr; | 	return ptr; | ||||||
|       newptr = _cmalloc (size); |       newptr = _cmalloc (size); | ||||||
| @@ -284,7 +282,7 @@ _crealloc (void *ptr, int size) | |||||||
| #define tocygheap(s) ((cygheap_entry *) (((char *) (s)) - (int) (N->data))) | #define tocygheap(s) ((cygheap_entry *) (((char *) (s)) - (int) (N->data))) | ||||||
|  |  | ||||||
| inline static void * | inline static void * | ||||||
| creturn (cygheap_types x, cygheap_entry * c, int len) | creturn (cygheap_types x, cygheap_entry * c, unsigned len) | ||||||
| { | { | ||||||
|   if (!c) |   if (!c) | ||||||
|     { |     { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user