malloc overrides
Dave Korn
dave.korn.cygwin@googlemail.com
Thu Nov 5 13:02:00 GMT 2009
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
More information about the Cygwin
mailing list