summaryrefslogtreecommitdiff
path: root/sdup.c
blob: e9907440df1a8cb88c6046a3a7c1a4aeb9b634c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "prv.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char *sdup(const char *s)
{
    char *n = malloc(strlen(s) + 1);

    if (n)
        strcpy(n, s);
    else
        perror("malloc(3)");

    return n;
}