File: strdup.c

package info (click to toggle)
mutt 2.2.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,908 kB
  • sloc: ansic: 95,475; sh: 5,169; perl: 2,137; python: 548; makefile: 485; sed: 16
file content (18 lines) | stat: -rw-r--r-- 307 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* 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;
}