From: | "Mike Frysinger (vapier)" <vapier@g.o> |
---|---|
To: | gentoo-commits@l.g.o |
Subject: | [gentoo-commits] gentoo-projects commit in portage-utils/libq: xstrdup.c |
Date: | Wed, 02 Mar 2011 08:12:49 |
Message-Id: | 20110302081240.34A182004F@flycatcher.gentoo.org |
1 | vapier 11/03/02 08:12:40 |
2 | |
3 | Modified: xstrdup.c |
4 | Log: |
5 | new xstrdup helper which returns len |
6 | |
7 | Revision Changes Path |
8 | 1.2 portage-utils/libq/xstrdup.c |
9 | |
10 | file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/xstrdup.c?rev=1.2&view=markup |
11 | plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/xstrdup.c?rev=1.2&content-type=text/plain |
12 | diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/xstrdup.c?r1=1.1&r2=1.2 |
13 | |
14 | Index: xstrdup.c |
15 | =================================================================== |
16 | RCS file: /var/cvsroot/gentoo-projects/portage-utils/libq/xstrdup.c,v |
17 | retrieving revision 1.1 |
18 | retrieving revision 1.2 |
19 | diff -u -r1.1 -r1.2 |
20 | --- xstrdup.c 13 Jun 2005 23:45:06 -0000 1.1 |
21 | +++ xstrdup.c 2 Mar 2011 08:12:40 -0000 1.2 |
22 | @@ -27,8 +27,7 @@ |
23 | #include <unistd.h> |
24 | #include <fcntl.h> |
25 | |
26 | -extern char *xstrdup(const char *s); |
27 | -extern char *xstrdup(const char *s) |
28 | +static char *xstrdup(const char *s) |
29 | { |
30 | char *t; |
31 | |
32 | @@ -41,3 +40,14 @@ |
33 | |
34 | return t; |
35 | } |
36 | + |
37 | +static char *xstrdup_len(const char *s, size_t *len) |
38 | +{ |
39 | + char *ret; |
40 | + |
41 | + *len = strlen(s); |
42 | + ret = xmalloc(*len + 1); |
43 | + memcpy(ret, s, *len + 1); |
44 | + |
45 | + return ret; |
46 | +} |