summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaul <paul>2004-10-31 16:19:24 +0000
committerpaul <paul>2004-10-31 16:19:24 +0000
commit9d11a19e6918d96d1466a5040bdf4228ec08d552 (patch)
tree18797b7c8496931b03d61e33c9ce00522deb88ae
parent66cbbcebc86bb3747073f133bdabf0102cb1229c (diff)
2004-10-31 Paul Jakma <paul@dishone.st>
* memory.h: Add MTYPE_THREAD_FUNCNAME and MTYPE_THREAD_STATS * thread.c: Update stats and funcname alloc/free to use previous specific memory type defines
-rw-r--r--lib/ChangeLog3
-rw-r--r--lib/memory.h2
-rw-r--r--lib/thread.c15
3 files changed, 13 insertions, 7 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 4d64e212..3dbf9ebc 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -4,6 +4,9 @@
(vty_serv_un) remove flags.
(vtysh_accept) close socket if we cant set NONBLOCK. Add flags.
* keychain.c: Convert some more strtoul users to VTY_GET_INTEGER.
+ * memory.h: Add MTYPE_THREAD_FUNCNAME and MTYPE_THREAD_STATS
+ * thread.c: Update stats and funcname alloc/free to use previous
+ specific memory type defines
2004-10-29 Paul Jakma <paul@dishone.st>
diff --git a/lib/memory.h b/lib/memory.h
index 2f403a14..1ffda558 100644
--- a/lib/memory.h
+++ b/lib/memory.h
@@ -34,6 +34,8 @@ enum
MTYPE_LINK_NODE,
MTYPE_THREAD,
MTYPE_THREAD_MASTER,
+ MTYPE_THREAD_STATS,
+ MTYPE_THREAD_FUNCNAME,
MTYPE_VTY,
MTYPE_VTY_HIST,
MTYPE_VTY_OUT_BUF,
diff --git a/lib/thread.c b/lib/thread.c
index e1625e39..94fdf1f5 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -104,10 +104,10 @@ static void*
cpu_record_hash_alloc (struct cpu_thread_history *a)
{
struct cpu_thread_history *new;
- new = XMALLOC( MTYPE_TMP/*XXX*/, sizeof *new);
- memset(new, 0, sizeof *new);
+ new = XMALLOC( MTYPE_THREAD_STATS, sizeof *new);
+ memset(new, 0, sizeof (struct cpu_thread_history));
new->func = a->func;
- new->funcname = XSTRDUP(MTYPE_TMP/*XXX*/,a->funcname);
+ new->funcname = XSTRDUP(MTYPE_THREAD_FUNCNAME, a->funcname);
return new;
}
@@ -317,6 +317,7 @@ thread_add_unuse (struct thread_master *m, struct thread *thread)
assert (thread->prev == NULL);
assert (thread->type == THREAD_UNUSED);
thread_list_add (&m->unuse, thread);
+ /* XXX: Should we deallocate funcname here? */
}
/* Free all unused thread. */
@@ -329,7 +330,7 @@ thread_list_free (struct thread_master *m, struct thread_list *list)
for (t = list->head; t; t = next)
{
next = t->next;
- XFREE (MTYPE_STRVEC, t->funcname);
+ XFREE (MTYPE_THREAD_FUNCNAME, t->funcname);
XFREE (MTYPE_THREAD, t);
list->count--;
m->alloc--;
@@ -401,7 +402,7 @@ strip_funcname (const char *funcname)
tmp = *e;
*e = '\0';
- ret = XSTRDUP (MTYPE_STRVEC, b);
+ ret = XSTRDUP (MTYPE_THREAD_FUNCNAME, b);
*e = tmp;
return ret;
@@ -418,7 +419,7 @@ thread_get (struct thread_master *m, u_char type,
{
thread = thread_trim_head (&m->unuse);
if (thread->funcname)
- XFREE(MTYPE_STRVEC, thread->funcname);
+ XFREE(MTYPE_THREAD_FUNCNAME, thread->funcname);
}
else
{
@@ -903,7 +904,7 @@ funcname_thread_execute (struct thread_master *m,
dummy.funcname = strip_funcname (funcname);
thread_call (&dummy);
- XFREE (MTYPE_STRVEC, dummy.funcname);
+ XFREE (MTYPE_THREAD_FUNCNAME, dummy.funcname);
return NULL;
}