Windows: rk_strdup allocator

patchset 3fe5572840 should have
replaced strdup().

Change-Id: I7af7b3e953e379fb23fccd9fa7a9e02c354c2dc4
This commit is contained in:
Jeffrey Altman
2012-07-20 00:50:47 -04:00
parent 13a6ac59ad
commit 0686ad5ece
2 changed files with 21 additions and 10 deletions

View File

@@ -3,22 +3,22 @@
* Copyright (c) 1995-2005 Kungliga Tekniska Högskolan * Copyright (c) 1995-2005 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* 3. Neither the name of the Institute nor the names of its contributors * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -65,7 +65,7 @@
#include <ws2tcpip.h> #include <ws2tcpip.h>
/* /*
* error codes for inet_ntop/inet_pton * error codes for inet_ntop/inet_pton
*/ */
typedef SOCKET rk_socket_t; typedef SOCKET rk_socket_t;
@@ -358,6 +358,7 @@ rk_vsnprintf (char *str, size_t sz, const char *format, va_list args);
#define free rk_free #define free rk_free
#define malloc rk_malloc #define malloc rk_malloc
#define realloc rk_realloc #define realloc rk_realloc
#define strdup rk_strdup
#endif #endif
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
@@ -372,6 +373,9 @@ rk_malloc(size_t);
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
rk_realloc(void *, size_t); rk_realloc(void *, size_t);
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_strdup(const char *);
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#ifdef HAVE_WINSOCK #ifdef HAVE_WINSOCK
@@ -441,7 +445,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
#ifndef HAVE_VSNPRINTF #ifndef HAVE_VSNPRINTF
#define vsnprintf rk_vsnprintf #define vsnprintf rk_vsnprintf
#endif #endif
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
rk_vsnprintf (char *, size_t, const char *, va_list) rk_vsnprintf (char *, size_t, const char *, va_list)
__attribute__((format (printf, 3, 0))); __attribute__((format (printf, 3, 0)));
#endif #endif
@@ -689,7 +693,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL innetgr(const char*, const char*,
#ifndef HAVE_IRUSEROK #ifndef HAVE_IRUSEROK
#define iruserok rk_iruserok #define iruserok rk_iruserok
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL iruserok(unsigned, int, ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL iruserok(unsigned, int,
const char *, const char *); const char *, const char *);
#endif #endif
@@ -944,7 +948,7 @@ getnameinfo_verified(const struct sockaddr *, socklen_t,
int); int);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **); roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **);
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **); roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **);
@@ -991,7 +995,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
roken_gethostby_setup(const char*, const char*); roken_gethostby_setup(const char*, const char*);
ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
roken_gethostbyname(const char*); roken_gethostbyname(const char*);
ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL ROKEN_LIB_FUNCTION struct hostent* ROKEN_LIB_CALL
roken_gethostbyaddr(const void*, size_t, int); roken_gethostbyaddr(const void*, size_t, int);
#ifdef GETSERVBYNAME_PROTO_COMPATIBLE #ifdef GETSERVBYNAME_PROTO_COMPATIBLE

View File

@@ -33,6 +33,7 @@
#undef calloc #undef calloc
#undef malloc #undef malloc
#undef free #undef free
#undef strdup
/* /*
* Windows executables and dlls suffer when memory is * Windows executables and dlls suffer when memory is
@@ -60,3 +61,9 @@ rk_malloc(size_t size)
{ {
return malloc( size); return malloc( size);
} }
ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
rk_strdup(const char *str)
{
return strdup( str);
}