Redefine strdup to make Windows happy

This commit is contained in:
Sam Ellicott 2020-05-19 23:19:58 -04:00
parent 6fdbe1df89
commit 2b0bb5a78d
5 changed files with 35 additions and 2 deletions

View file

@ -10,6 +10,13 @@
#include <stdio.h>
#include <malloc.h>
#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \
|| defined(_WIN32) || defined(_WIN64)
#ifndef strdup
#define strdup _strdup
#endif
#endif
#define I_AM_LITTLE (((union { unsigned x; unsigned char c; }){1}).c)
static unsigned long GetStrHash( const char * c )
@ -126,7 +133,7 @@ void ** HashTableInsert( struct chash * hash, const char * key, int dontDupKey )
}
else
{
thisEntry->key = strdup( key );
thisEntry->key = _strdup( key );
}
thisEntry->hash = thisHash;

View file

@ -58,6 +58,13 @@ typedef LONG NTSTATUS;
/*#define HIDAPI_USE_DDK*/
#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \
|| defined(_WIN32) || defined(_WIN64)
#ifndef strdup
#define strdup _strdup
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif

View file

@ -1,9 +1,14 @@
//Copyright 2015 <>< Charles Lohr under the ColorChord License.
#if defined(WIN32) || defined(USE_WINDOWS)
#if defined(WINDOWS) || defined(USE_WINDOWS)\
|| defined(WIN32) || defined(WIN64) \
|| defined(_WIN32) || defined(_WIN64)
#include <winsock2.h>
#include <windows.h>
#ifndef strdup
#define strdup _strdup
#endif
#endif
#include <ctype.h>
#include "color.h"

View file

@ -7,6 +7,13 @@
#include <stdio.h>
#include <stdlib.h>
#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \
|| defined(_WIN32) || defined(_WIN64)
#ifndef strdup
#define strdup _strdup
#endif
#endif
int force_white = 0;
unsigned char OutLEDs[MAX_LEDS*3];
int UsedLEDs;

View file

@ -6,6 +6,13 @@
#include <stdio.h>
#include <stdlib.h>
#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \
|| defined(_WIN32) || defined(_WIN64)
#ifndef strdup
#define strdup _strdup
#endif
#endif
static struct chash * parameters;
//XXX TODO: Make this thread safe.