]> git.pond.sub.org Git - empserver/commitdiff
Allow any length thread names for WIN32
authorRon Koenderink <rkoenderink@yahoo.ca>
Sat, 13 Sep 2008 21:18:29 +0000 (15:18 -0600)
committerRon Koenderink <rkoenderink@yahoo.ca>
Sat, 13 Sep 2008 21:29:42 +0000 (15:29 -0600)
Dynamically allocate the string space for thread
name in WIN32 (ntthread.c) thread space.  This
makes the WIN32 more consistent with the other
environments.  It also addresses WIN32 issue of
the print width of 17 being used and only having
space for 16 characters in the fixed allocation.

src/lib/empthread/ntthread.c

index dd57a158399a02781c7f79e820ca0862aa41062a..b8d2ab8b28048b3f90d731ab8b524e0c43f1479f 100644 (file)
@@ -73,7 +73,7 @@
 struct loc_Thread {
 
     /* The thread name, passed in at create time. */
-    char szName[17];
+    char *szName;
 
     /* True if this is the main line, and not a real thread. */
     BOOL bMainThread;
@@ -224,6 +224,8 @@ loc_FreeThreadInfo(empth_t *pThread)
     if (pThread) {
        if (pThread->hThreadEvent)
            CloseHandle(pThread->hThreadEvent);
+       if (pThread->szName != NULL)
+           free(pThread->szName);
        memset(pThread, 0, sizeof(*pThread));
        free(pThread);
     }
@@ -403,7 +405,7 @@ empth_init(void **ctx_ptr, int flags)
     }
     memset(pThread, 0, sizeof(*pThread));
 
-    strncpy(pThread->szName, "Main", sizeof(pThread->szName) - 1);
+    pThread->szName = strdup("Main");
     pThread->ulThreadID = GetCurrentThreadId();
     pThread->bMainThread = TRUE;
 
@@ -446,7 +448,7 @@ empth_create(void (*entry)(void *), int size, int flags,
     }
     memset(pThread, 0, sizeof(*pThread));
 
-    strncpy(pThread->szName, name, sizeof(pThread->szName) - 1);
+    pThread->szName = strdup(name);
     pThread->pvUserData = ud;
     pThread->pfnEntry = entry;
     pThread->bMainThread = FALSE;
@@ -502,7 +504,9 @@ empth_name(empth_t *thread)
 void
 empth_set_name(empth_t *thread, char *name)
 {
-    strncpy(thread->szName, name, sizeof(thread->szName) - 1);
+    if (thread->szName != NULL)
+       free(thread->szName);
+    thread->szName = strdup(name);
 }
 
 /************************