cachetimestampsdeveloprc-4.0.4ringdecrementfixringperformance
Last change
on this file since 49f8ceb was
823d8e1,
checked in by Alistair King <alistair@…>, 3 years ago
|
Replace AC_CHECK_FUNCS with AC_CHECK_DECLS
It seems that AC_CHECK_FUNCS does not correctly detect when these "functions" are implemented as macros. (I've seen this happening on macOS, and Ubuntu 16.04 with snprintf and strndup respectively.) Replacing AC_CHECK_FUNCS (and the similar AC_REPLACE_FUNCS) with AC_CHECK_DECLS seems to solve this problem, though I don't have access to any systems that do not have these functions to be sure that it correctly detects them as missing.
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Line | |
---|
1 | /* |
---|
2 | * |
---|
3 | * Copyright (c) 2007-2016 The University of Waikato, Hamilton, New Zealand. |
---|
4 | * All rights reserved. |
---|
5 | * |
---|
6 | * This file is part of libtrace. |
---|
7 | * |
---|
8 | * This code has been developed by the University of Waikato WAND |
---|
9 | * research group. For further information please see http://www.wand.net.nz/ |
---|
10 | * |
---|
11 | * libtrace is free software; you can redistribute it and/or modify |
---|
12 | * it under the terms of the GNU Lesser General Public License as published by |
---|
13 | * the Free Software Foundation; either version 3 of the License, or |
---|
14 | * (at your option) any later version. |
---|
15 | * |
---|
16 | * libtrace is distributed in the hope that it will be useful, |
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | * GNU Lesser General Public License for more details. |
---|
20 | * |
---|
21 | * You should have received a copy of the GNU Lesser General Public License |
---|
22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
23 | * |
---|
24 | * |
---|
25 | */ |
---|
26 | #include "config.h" |
---|
27 | #if !HAVE_DECL_STRNDUP |
---|
28 | |
---|
29 | #include <stdlib.h> |
---|
30 | #include <errno.h> |
---|
31 | #include <string.h> |
---|
32 | |
---|
33 | #include <libtrace_int.h> |
---|
34 | |
---|
35 | /* Some systems don't include strndup as part of their standard C library, so |
---|
36 | * we need to provide our own version. |
---|
37 | * |
---|
38 | * Full credit to Matthew Luckie, who wrote this particular version and allowed |
---|
39 | * us to borrow it. |
---|
40 | */ |
---|
41 | |
---|
42 | char *strndup(const char *s, size_t size) |
---|
43 | { |
---|
44 | char *str; |
---|
45 | size_t len; |
---|
46 | |
---|
47 | if(size == 0 || s == NULL) |
---|
48 | { |
---|
49 | errno = EINVAL; |
---|
50 | return NULL; |
---|
51 | } |
---|
52 | |
---|
53 | if(size > (len = strlen(s))) |
---|
54 | { |
---|
55 | size = len+1; |
---|
56 | } |
---|
57 | |
---|
58 | if((str = malloc(size)) == NULL) |
---|
59 | { |
---|
60 | errno = ENOMEM; |
---|
61 | return NULL; |
---|
62 | } |
---|
63 | |
---|
64 | memcpy(str, s, size); |
---|
65 | str[size-1] = '\0'; |
---|
66 | |
---|
67 | return str; |
---|
68 | } |
---|
69 | |
---|
70 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.