Mail Archives: cygwin-developers/2001/09/06/13:27:53
On Thu, Sep 06, 2001 at 12:49:35PM -0400, Christopher Faylor wrote:
> In the meantime, if you could check out the enclosed patch and verify
> or disappoint, I'd be grateful.
What exactly should HEAP_FREE be defined as??? Currently it isn't
anywhere.
Corinna
>
> For the curious, most of the patch is actually just replacing
> cygheap->buckets with a macro so that I could switch back and forth
> between the static array and the cygheap->buckets.
>
> cgf
>
> Index: cygheap.cc
> ===================================================================
> RCS file: /cvs/uberbaum/winsup/cygwin/cygheap.cc,v
> retrieving revision 1.37
> diff -p -r1.37 cygheap.cc
> *** cygheap.cc 2001/09/06 03:39:18 1.37
> --- cygheap.cc 2001/09/06 16:47:38
> *************** struct cygheap_entry
> *** 36,41 ****
> --- 36,43 ----
> };
>
> #define NBUCKETS (sizeof (cygheap->buckets) / sizeof (cygheap->buckets[0]))
> + #define cygbuckets cygheap->buckets
> +
> #define N0 ((_cmalloc_entry *) NULL)
> #define to_cmalloc(s) ((_cmalloc_entry *) (((char *) (s)) - (int) (N0->data)))
>
> *************** cygheap_fixup_in_child (child_info *ci,
> *** 136,142 ****
> for (_cmalloc_entry *rvc = cygheap->chain; rvc; rvc = rvc->prev)
> {
> cygheap_entry *ce = (cygheap_entry *) rvc->data;
> ! if (rvc->b >= NBUCKETS || ce->type <= HEAP_1_START)
> continue;
> else if (ce->type < HEAP_1_MAX)
> ce->type += HEAP_1_MAX; /* Mark for freeing after next exec */
> --- 138,144 ----
> for (_cmalloc_entry *rvc = cygheap->chain; rvc; rvc = rvc->prev)
> {
> cygheap_entry *ce = (cygheap_entry *) rvc->data;
> ! if (ce->type < HEAP_1_START)
> continue;
> else if (ce->type < HEAP_1_MAX)
> ce->type += HEAP_1_MAX; /* Mark for freeing after next exec */
> *************** _cmalloc (int size)
> *** 200,209 ****
> continue;
>
> cygheap_protect->acquire ();
> ! if (cygheap->buckets[b])
> {
> ! rvc = (_cmalloc_entry *) cygheap->buckets[b];
> ! cygheap->buckets[b] = rvc->ptr;
> rvc->b = b;
> }
> else
> --- 202,211 ----
> continue;
>
> cygheap_protect->acquire ();
> ! if (cygbuckets[b])
> {
> ! rvc = (_cmalloc_entry *) cygbuckets[b];
> ! cygbuckets[b] = rvc->ptr;
> rvc->b = b;
> }
> else
> *************** static void __stdcall
> *** 223,232 ****
> _cfree (void *ptr)
> {
> cygheap_protect->acquire ();
> _cmalloc_entry *rvc = to_cmalloc (ptr);
> DWORD b = rvc->b;
> ! rvc->ptr = cygheap->buckets[b];
> ! cygheap->buckets[b] = (char *) rvc;
> cygheap_protect->release ();
> }
>
> --- 225,235 ----
> _cfree (void *ptr)
> {
> cygheap_protect->acquire ();
> + ((cygheap_entry *) ptr)->type = HEAP_FREE;
> _cmalloc_entry *rvc = to_cmalloc (ptr);
> DWORD b = rvc->b;
> ! rvc->ptr = cygbuckets[b];
> ! cygbuckets[b] = (char *) rvc;
> cygheap_protect->release ();
> }
>
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin AT cygwin DOT com
Red Hat, Inc.
- Raw text -