File: strdup.c

package info (click to toggle)
html-xml-utils 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,620 kB
  • sloc: ansic: 10,027; sh: 2,135; lex: 189; yacc: 125; perl: 123; makefile: 122
file content (22 lines) | stat: -rw-r--r-- 552 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * Copyright  1994-2000 World Wide Web Consortium
 * See http://www.w3.org/Consortium/Legal/copyright-software
 *
 * Author: Bert Bos <bert@w3.org>
 * Created: 31 Mar 2000
 * Version: $Id: strdup.c,v 1.2 2007/10/23 11:17:08 bbos Exp $
 **/
#include <config.h>
#include <stdlib.h>
#include "export.h"

#ifndef HAVE_STRDUP
/* strdup -- allocate a copy of a string on the heap; NULL if no memory */
EXPORT char *strdup(const char *s)
{
  char *t;

  if ((t = malloc((strlen(s) + 1) * sizeof(*s)))) strcpy(t, s);
  return t;
}
#endif /* HAVE_STRDUP */