This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: malloc overrides


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]