File: strdup.c

package info (click to toggle)
mutt 1.5.18-6
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 14,368 kB
  • ctags: 5,213
  • sloc: ansic: 77,749; sh: 4,230; perl: 984; makefile: 707; yacc: 318; awk: 17
file content (19 lines) | stat: -rw-r--r-- 312 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* ultrix doesn't have strdup */

#include <string.h>
#include <stdlib.h>

char *strdup (const char *s)	/* __MEM_CHECKED__ */
{
  char *d;
  
  if (s == NULL)
    return NULL;
  
  if ((d = malloc (strlen (s) + 1)) == NULL)	/* __MEM_CHECKED__ */
    return NULL;

  memcpy (d, s, strlen (s) + 1);
  return d;
}