| Last change
 on this file since 3299 was             2, checked in by bird, 23 years ago | 
        
          | 
Initial revision
 | 
        
          | 
              
Property                 cvs2svn:cvs-rev
 set to                 1.1
Property                 svn:eol-style
 set to                 native
Property                 svn:executable
 set to                 * | 
        
          | File size:
            388 bytes | 
      
      
| Line |  | 
|---|
| 1 | /* | 
|---|
| 2 |  | 
|---|
| 3 | @deftypefn Supplemental char* strdup (const char *@var{s}) | 
|---|
| 4 |  | 
|---|
| 5 | Returns a pointer to a copy of @var{s} in memory obtained from | 
|---|
| 6 | @code{malloc}, or @code{NULL} if insufficient memory was available. | 
|---|
| 7 |  | 
|---|
| 8 | @end deftypefn | 
|---|
| 9 |  | 
|---|
| 10 | */ | 
|---|
| 11 |  | 
|---|
| 12 | char * | 
|---|
| 13 | strdup(s) | 
|---|
| 14 | char *s; | 
|---|
| 15 | { | 
|---|
| 16 | char *result = (char*)malloc(strlen(s) + 1); | 
|---|
| 17 | if (result == (char*)0) | 
|---|
| 18 | return (char*)0; | 
|---|
| 19 | strcpy(result, s); | 
|---|
| 20 | return result; | 
|---|
| 21 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.