* cygheap.h (enum cygheap_types): Add HEAP_MMAP.

(CYGHEAPSIZE): Add another 64K.
* mmap.cc: Use cmalloc, ccalloc and crealloc with HEAP_MMAP type throughout.
This commit is contained in:
Christopher Faylor 2003-08-23 00:03:54 +00:00
parent 7f32ba3a8d
commit 5c6497b43f
3 changed files with 19 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2003-08-22 Corinna Vinschen <corinna@vinschen.de>
* cygheap.h (enum cygheap_types): Add HEAP_MMAP.
(CYGHEAPSIZE): Add another 64K.
* mmap.cc: Use cmalloc, ccalloc and crealloc with HEAP_MMAP type
throughout.
2003-08-22 Christopher Faylor <cgf@redhat.com> 2003-08-22 Christopher Faylor <cgf@redhat.com>
* cygheap.cc (user_heap_info::max): New field. * cygheap.cc (user_heap_info::max): New field.

View File

@ -22,7 +22,8 @@ enum cygheap_types
HEAP_1_ARGV, HEAP_1_ARGV,
HEAP_1_BUF, HEAP_1_BUF,
HEAP_1_EXEC, HEAP_1_EXEC,
HEAP_1_MAX = 100 HEAP_1_MAX = 100,
HEAP_MMAP = 200
}; };
#define incygheap(s) (cygheap && ((char *) (s) >= (char *) cygheap) && ((char *) (s) <= ((char *) cygheap_max))) #define incygheap(s) (cygheap && ((char *) (s) >= (char *) cygheap) && ((char *) (s) <= ((char *) cygheap_max)))
@ -256,7 +257,7 @@ struct init_cygheap
#endif #endif
}; };
#define CYGHEAPSIZE (sizeof (init_cygheap) + (16000 * sizeof (fhandler_union)) + (4 * 65536)) #define CYGHEAPSIZE (sizeof (init_cygheap) + (16000 * sizeof (fhandler_union)) + (5 * 65536))
extern init_cygheap *cygheap; extern init_cygheap *cygheap;
extern void *cygheap_max; extern void *cygheap_max;

View File

@ -76,7 +76,7 @@ class mmap_record
caddr_t get_address () const { return base_address_; } caddr_t get_address () const { return base_address_; }
DWORD *get_map () const { return map_map_; } DWORD *get_map () const { return map_map_; }
void alloc_map (_off64_t off, DWORD len); void alloc_map (_off64_t off, DWORD len);
void free_map () { if (map_map_) free (map_map_); } void free_map () { if (map_map_) cfree (map_map_); }
DWORD find_empty (DWORD pages); DWORD find_empty (DWORD pages);
_off64_t map_map (_off64_t off, DWORD len); _off64_t map_map (_off64_t off, DWORD len);
@ -113,8 +113,8 @@ void
mmap_record::alloc_map (_off64_t off, DWORD len) mmap_record::alloc_map (_off64_t off, DWORD len)
{ {
/* Allocate one bit per page */ /* Allocate one bit per page */
map_map_ = (DWORD *) calloc (MAPSIZE (PAGE_CNT (size_to_map_)), map_map_ = (DWORD *) ccalloc (HEAP_MMAP, MAPSIZE (PAGE_CNT (size_to_map_)),
sizeof (DWORD)); sizeof (DWORD));
if (wincap.virtual_protect_works_on_shared_pages ()) if (wincap.virtual_protect_works_on_shared_pages ())
{ {
DWORD old_prot; DWORD old_prot;
@ -277,14 +277,14 @@ public:
list::list () list::list ()
: nrecs (0), maxrecs (10), fd (0), hash (0) : nrecs (0), maxrecs (10), fd (0), hash (0)
{ {
recs = (mmap_record *) malloc (10 * sizeof (mmap_record)); recs = (mmap_record *) cmalloc (HEAP_MMAP, 10 * sizeof (mmap_record));
} }
list::~list () list::~list ()
{ {
for (mmap_record *rec = recs; nrecs-- > 0; ++rec) for (mmap_record *rec = recs; nrecs-- > 0; ++rec)
rec->free_map (); rec->free_map ();
free (recs); cfree (recs);
} }
mmap_record * mmap_record *
@ -293,7 +293,7 @@ list::add_record (mmap_record r, _off64_t off, DWORD len)
if (nrecs == maxrecs) if (nrecs == maxrecs)
{ {
maxrecs += 5; maxrecs += 5;
recs = (mmap_record *) realloc (recs, maxrecs * sizeof (mmap_record)); recs = (mmap_record *) crealloc (recs, maxrecs * sizeof (mmap_record));
} }
recs[nrecs] = r; recs[nrecs] = r;
recs[nrecs].alloc_map (off, len); recs[nrecs].alloc_map (off, len);
@ -373,14 +373,14 @@ public:
map::map () map::map ()
{ {
lists = (list **) malloc (10 * sizeof (list *)); lists = (list **) cmalloc (HEAP_MMAP, 10 * sizeof (list *));
nlists = 0; nlists = 0;
maxlists = 10; maxlists = 10;
} }
map::~map () map::~map ()
{ {
free (lists); cfree (lists);
} }
list * list *
@ -408,7 +408,7 @@ map::add_list (list *l, int fd)
if (nlists == maxlists) if (nlists == maxlists)
{ {
maxlists += 5; maxlists += 5;
lists = (list **) realloc (lists, maxlists * sizeof (list *)); lists = (list **) crealloc (lists, maxlists * sizeof (list *));
} }
lists[nlists++] = l; lists[nlists++] = l;
return lists[nlists-1]; return lists[nlists-1];