Re: replace alloca with strdup

2005-05-22 Thread Richard Stallman
While looking at some compilerwarnings I found an alloca and an strcpy. What is wrong with that? I don't see any problem in it. And I realized this can also be done as follows: + if ((error_msg = strdup(error_message)) == NULL) +errx(1, "Out of memory."); This

Re: replace alloca with strdup

2005-05-21 Thread Andreas Schwab
Han Boetes <[EMAIL PROTECTED]> writes: > Advantages are: > > - simpler code Not really. > - strdup is more portable Not more than alloca. > - error handling Which error? > - you don't have to worry about strdup concerning security The code you changed is already obviously safe. > I

Re: replace alloca with strdup

2005-05-21 Thread David Kastrup
Han Boetes <[EMAIL PROTECTED]> writes: > While looking at some compilerwarnings I found an alloca and an > strcpy. And I realized this can also be done as follows: > > > Index: xterm.c > === > RCS file: /cvsroot/emacs/emacs/src/xterm

Re: replace alloca with strdup

2005-05-21 Thread Masatake YAMATO
Hi, > - error_msg = (char *) alloca (strlen (error_message) + 1); > - strcpy (error_msg, error_message); > + if ((error_msg = strdup(error_message)) == NULL) > +errx(1, "Out of memory."); > + I wonder who will release the memory chunk allocated by strdup.