1From e6f124779d1c1edd050a6fc42389fcfdbd03915a Mon Sep 17 00:00:00 2001 2From: Gisle Vanem <gvanem@yahoo.no> 3Date: Mon, 9 Sep 2019 10:27:08 +0200 4Subject: [PATCH] Fixes in Mongoose for MSVC debug-mode (-MDd) (#1146) 5 6In debug-mode (_DEBUG is defined), 'strdup()' is already defined to '_strdmp_dbg()'. 7And 'free()' is defined to '_free_dbg()'. 8--- 9 include/mongoose.h | 4 ++-- 10 src/mongoose.c | 4 ++-- 11 2 files changed, 4 insertions(+), 4 deletions(-) 12 13diff --git a/include/mongoose.h b/include/mongoose.h 14index 57c12af..f2b8891 100644 15--- a/include/mongoose.h 16+++ b/include/mongoose.h 17@@ -227,7 +227,7 @@ typedef int bool; 18 #include <stdbool.h> 19 #endif 20 21-#if defined(_MSC_VER) && _MSC_VER >= 1800 22+#if defined(_MSC_VER) && (_MSC_VER >= 1800) && !defined(_DEBUG) 23 #define strdup _strdup 24 #endif 25 26@@ -3634,7 +3634,7 @@ struct mg_iface { 27 28 struct mg_iface_vtable { 29 void (*init)(struct mg_iface *iface); 30- void (*free)(struct mg_iface *iface); 31+ void (*_free)(struct mg_iface *iface); 32 void (*add_conn)(struct mg_connection *nc); 33 void (*remove_conn)(struct mg_connection *nc); 34 time_t (*poll)(struct mg_iface *iface, int timeout_ms); 35diff --git a/src/mongoose.c b/src/mongoose.c 36index 593f8c6..c68a627 100644 37--- a/src/mongoose.c 38+++ b/src/mongoose.c 39@@ -2577,7 +2577,7 @@ void mg_mgr_free(struct mg_mgr *m) { 40 { 41 int i; 42 for (i = 0; i < m->num_ifaces; i++) { 43- m->ifaces[i]->vtable->free(m->ifaces[i]); 44+ m->ifaces[i]->vtable->_free(m->ifaces[i]); 45 MG_FREE(m->ifaces[i]); 46 } 47 MG_FREE(m->ifaces); 48@@ -4494,7 +4494,7 @@ static int mg_socks_if_create_conn(struct mg_connection *c) { 49 } 50 51 static void mg_socks_if_destroy_conn(struct mg_connection *c) { 52- c->iface->vtable->free(c->iface); 53+ c->iface->vtable->_free(c->iface); 54 MG_FREE(c->iface); 55 c->iface = NULL; 56 LOG(LL_DEBUG, ("%p", c)); 57 58