lib: do not allocate/free thread funcnames
This avoids memory heap fragmentation and imposses less load on the
system memory allocator.
* thread.h: FUNCNAME_LEN defined to 64 (ISO C99 says max 63)
Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
[changed FUNCNAME_LEN to a less arbitrary value]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/lib/thread.h b/lib/thread.h
index 56f4d07..67902cf 100644
--- a/lib/thread.h
+++ b/lib/thread.h
@@ -62,6 +62,9 @@
typedef unsigned char thread_type;
+/* ISO C99 maximum function name length is 63 */
+#define FUNCNAME_LEN 64
+
/* Thread itself. */
struct thread
{
@@ -79,13 +82,12 @@
} u;
struct timeval real;
struct cpu_thread_history *hist; /* cache pointer to cpu_history */
- char* funcname;
+ char funcname[FUNCNAME_LEN];
};
struct cpu_thread_history
{
int (*func)(struct thread *);
- char *funcname;
unsigned int total_calls;
struct time_stats
{
@@ -95,6 +97,7 @@
struct time_stats cpu;
#endif
thread_type types;
+ char funcname[FUNCNAME_LEN];
};
/* Clocks supported by Quagga */