From 10d3d90f06117e3740d9915e7df9a9ba80e608c5 Mon Sep 17 00:00:00 2001 From: Zachary Rasmor Date: Sat, 5 Dec 2015 19:56:55 -0500 Subject: [PATCH] Change thread name from pointer to buffer. Remove pointer free. --- src/threadvars.h | 2 +- src/tm-threads.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/threadvars.h b/src/threadvars.h index 578770c1aa..c72dcc734d 100644 --- a/src/threadvars.h +++ b/src/threadvars.h @@ -64,7 +64,7 @@ struct TmSlot_; /** \brief Per thread variable structure */ typedef struct ThreadVars_ { pthread_t t; - char *name; + char name[16]; char *thread_group_name; SC_ATOMIC_DECLARE(unsigned int, flags); diff --git a/src/tm-threads.c b/src/tm-threads.c index ad460232a7..b21357871e 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -1162,9 +1162,8 @@ ThreadVars *TmThreadCreate(char *name, char *inq_name, char *inqh_name, SC_ATOMIC_INIT(tv->flags); SCMutexInit(&tv->perf_public_ctx.m, NULL); - tv->name = SCStrdup(name); - if (unlikely(tv->name == NULL)) - goto error; + strlcpy(tv->name, name, sizeof(tv->name)); + /* default state for every newly created thread */ TmThreadsSetFlag(tv, THV_PAUSE); TmThreadsSetFlag(tv, THV_USE); @@ -1793,7 +1792,6 @@ void TmThreadFree(ThreadVars *tv) } TmThreadsUnregisterThread(tv->id); - SCFree(tv->name); SCFree(tv); } -- 2.47.2