This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: malloc overrides
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 05 Nov 2009 13:18:09 +0000
- Subject: Re: malloc overrides
- References: <4AF29EC2.2050808@users.sourceforge.net>
Yaakov (Cygwin/X) wrote:
> ####### start code 1 #######
>
> /* Are we stuck with standard malloc? */
>
> 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);
> }
>
> ####### end code 1 #######
FTFY.
> ####### start code 2 #######
>
> /* Is alloca is based on malloc()? */
>
> #include <alloca.h>
>
> void* malloc(unsigned int size) {
> exit(0);
> return 0;
> }
>
> int main(void) {
> alloca(10);
> return 1;
> }
>
> ####### end code 1 #######
Left as an exercise for the reader.
cheers,
DaveK
--
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