delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/06/30/22:04:35

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Date: Fri, 30 Jun 2000 22:04:01 -0400 (EDT)
From: "Ashif S. Harji" <asharji AT plg2 DOT math DOT uwaterloo DOT ca>
To: cygwin AT sourceware DOT cygnus DOT com
Subject: user defined malloc
Message-ID: <Pine.SOL.3.96.1000630214754.5827A-100000@plg2.math.uwaterloo.ca>
MIME-Version: 1.0

It mentions in the faq that it is possible to override the default malloc
routine.  The problem that I am having is that there is at least one
occasion when my malloc routine is not called for memory allocation.
Instead the function _malloc_r is called directly.  This by passes my
malloc which results in already allocated memory being reallocated.

This direct call to _malloc_r occurs in the __sfmoreglue function in the
file findfp.c:

struct _glue *
__sfmoreglue (d, n)
     struct _reent *d;
     register int n;
{
  struct _glue *g;
  FILE *p;

  g = (struct _glue *) _malloc_r (d, sizeof (*g) + n * sizeof (FILE));
  if (g == NULL)
    return NULL;
  p = (FILE *) (g + 1);
  g->_next = NULL;
  g->_niobs = n;
  g->_iobs = p;
  memset (p, 0, n * sizeof (FILE));
  return g;
}

While I am not sure exactly what this function does, it appears to be
related to opening the /etc/passwd file and occurs even with an empty C++
program:

int main(){}


My question is do I have to also override the _malloc_r routine, and if
so, could someone provide some information or a link on what is required? 
It appears to be a reentrant version of malloc. 

thanks,
ashif harji.


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019