-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathutils.c
56 lines (53 loc) · 1.44 KB
/
utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* ipgen is Copyright (C) 2012 Roy Hills, NTA Monitor Ltd.
*
* This file is part of ipgen.
*
* ipgen is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ipgen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ipgen. If not, see <http://www.gnu.org/licenses/>.
*
* You are encouraged to send comments, improvements or suggestions to
* me at [email protected].
*
* Author: Roy Hills
* Date: 5 April 2004
*
* This file contains various utility functions used by ipgen.
*/
#include "ipgen.h"
/*
* dupstr -- duplicate a string
*
* Inputs:
*
* str The string to duplcate
*
* Returns:
*
* A pointer to the duplicate string.
*
* This is a replacement for the common but non-standard "strdup"
* function.
*
* The returned pointer points to Malloc'ed memory, which must be
* free'ed by the caller.
*/
char *
dupstr(const char *str) {
char *cp;
size_t len;
len = strlen(str) + 1; /* Allow space for terminating NULL */
cp = Malloc(len);
strlcpy(cp, str, len);
return cp;
}