Check for predefined strlcpy (as in newer gcc versions)

This commit is contained in:
2013-11-06 09:29:55 +01:00
parent 19a939ec26
commit 6531dc4ae2
3 changed files with 11 additions and 6 deletions
-2
View File
@@ -5,8 +5,6 @@
Contents: Header file for mxml.c
$Id$
\********************************************************************/
/*------------------------------------------------------------------*/
+4 -2
View File
@@ -6,8 +6,6 @@
Contents: Contains strlcpy and strlcat which are versions of
strcpy and strcat, but which avoid buffer overflows
$Id:$
\********************************************************************/
#include <stdio.h>
@@ -19,6 +17,8 @@
* will be copied. Always NUL terminates (unless size == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
#ifndef STRLCPY_DEFINED
size_t strlcpy(char *dst, const char *src, size_t size)
{
char *d = dst;
@@ -80,3 +80,5 @@ size_t strlcat(char *dst, const char *src, size_t size)
}
/*-------------------------------------------------------------------*/
#endif // STRLCPY_DEFINED
+7 -2
View File
@@ -5,13 +5,16 @@
Contents: Header file for strlcpy.c
$Id$
\********************************************************************/
#ifndef _STRLCPY_H_
#define _STRLCPY_H_
// some version of gcc have a built-in strlcpy
#ifdef strlcpy
#define STRLCPY_DEFINED
#endif
#ifdef __cplusplus
extern "C" {
#endif
@@ -24,8 +27,10 @@ extern "C" {
#endif
#endif
#ifndef STRLCPY_DEFINED
size_t EXPRT strlcpy(char *dst, const char *src, size_t size);
size_t EXPRT strlcat(char *dst, const char *src, size_t size);
#endif
#ifdef __cplusplus
}