delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS |
X-Spam-Check-By: | sourceware.org |
MIME-Version: | 1.0 |
In-Reply-To: | <4AF30A85.5070208@users.sourceforge.net> |
References: | <4AF29EC2 DOT 2050808 AT users DOT sourceforge DOT net> <4AF2D091 DOT 4030508 AT gmail DOT com> <4AF30A85 DOT 5070208 AT users DOT sourceforge DOT net> |
Date: | Thu, 5 Nov 2009 18:22:18 +0000 |
Message-ID: | <416096c60911051022obc335ceu15dc7ee0e487cb66@mail.gmail.com> |
Subject: | Re: malloc overrides |
From: | Andy Koppe <andy DOT koppe AT gmail DOT com> |
To: | cygwin AT cygwin DOT com |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
2009/11/5 Yaakov (Cygwin/X): >>> extern void _exit (int); >>> extern char* strdup (const char*); >> >> =C2=A0 static int are_we_stuck =3D 1; >>> >>> char* malloc(unsigned n) { >> >> =C2=A0 =C2=A0 =C2=A0 are_we_stuck =3D 0; >>> >>> =C2=A0 =C2=A0 return 0; >>> } >>> >>> int main(void) { >>> =C2=A0 =C2=A0 strdup("yo"); >> >> =C2=A0 =C2=A0 =C2=A0 _exit (are_we_stuck); >>> >>> } >> >> =C2=A0 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 answ= er > either. =C2=A0 As Corinna said, the malloc override needs to be functiona= l, in > that it allocates memory which can then be free()d. =C2=A0So this isn't g= oing to > be quite so simple. :-( Does the memory actually need to be freed? The simplest implementation of malloc() simply advances a pointer into an array (taking alignment into account), and the simplest implementation of free() does nothing. Andy -- 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |