From 8dd76e6ef47eb10051cc9630c32f8a40a3d97c55 Mon Sep 17 00:00:00 2001
From: Sergey Lyubka <valenok@gmail.com>
Date: Sun, 9 Mar 2014 19:50:34 +0000
Subject: [PATCH] Using ns_start_thread()

---
 mongoose.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/mongoose.c b/mongoose.c
index b59909a95..1d51e86c5 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -1250,24 +1250,7 @@ static const struct {
 
 #ifndef MONGOOSE_NO_THREADS
 void *mg_start_thread(void *(*f)(void *), void *p) {
-#ifdef _WIN32
-  return (void *) _beginthread((void (__cdecl *)(void *)) f, 0, p);
-#else
-  pthread_t thread_id = (pthread_t) 0;
-  pthread_attr_t attr;
-
-  (void) pthread_attr_init(&attr);
-  (void) pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
-#if MONGOOSE_USE_STACK_SIZE > 1
-  (void) pthread_attr_setstacksize(&attr, MONGOOSE_USE_STACK_SIZE);
-#endif
-
-  pthread_create(&thread_id, &attr, f, p);
-  pthread_attr_destroy(&attr);
-
-  return (void *) thread_id;
-#endif
+  return ns_start_thread(f, p);
 }
 #endif  // MONGOOSE_NO_THREADS
 
-- 
GitLab