malloc overrides

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Nov 5 18:24:00 GMT 2009


On Nov  5 18:22, Andy Koppe wrote:
> 2009/11/5 Yaakov (Cygwin/X):
> >>> extern void _exit (int);
> >>> extern char* strdup (const char*);
> >>
> >>   static int are_we_stuck = 1;
> >>>
> >>> char* malloc(unsigned n) {
> >>
> >>       are_we_stuck = 0;
> >>>
> >>>     return 0;
> >>> }
> >>>
> >>> int main(void) {
> >>>     strdup("yo");
> >>
> >>       _exit (are_we_stuck);
> >>>
> >>> }
> >>
> >>   FTFY.
> >
> > Funny, as I went to sleep last night I thought of just that solution. In
> > practice, though, while it doesn't hang, it doesn't give the correct answer
> > either.   As Corinna said, the malloc override needs to be functional, in
> > that it allocates memory which can then be free()d.  So this isn't going to
> > be quite so simple. :-(
> 
> Does the memory actually need to be freed?

Cygwin itself calls free, so the application implementation has to
provide both.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list