]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
sched: Dont use fixed-size buffer for task names.
authorAndre Noll <maan@systemlinux.org>
Thu, 2 Jan 2014 01:16:33 +0000 (01:16 +0000)
committerAndre Noll <maan@systemlinux.org>
Sun, 25 May 2014 13:39:01 +0000 (15:39 +0200)
This is not more complicated than the strncpy(), and it allows for
arbitrary long task names.

sched.c

diff --git a/sched.c b/sched.c
index b92774fa95d4d1a0e4870c6e58a42130bc9bbe5b..0a1cff28521dfe12c8f75316b1a1ce35206c1918 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -20,7 +20,7 @@
 
 struct task {
        /** The task name supplied when the task was registered(). */
-       char name[255];
+       char *name;
        /** Copied from the task_info struct during task_register(). */
        void (*pre_select)(struct sched *s, struct task *t);
        /** Copied from the task_info struct during task_register(). */
@@ -64,6 +64,7 @@ static void unlink_and_free_task(struct task *t)
 {
        PARA_INFO_LOG("freeing task %s\n", t->name);
        list_del(&t->node);
+       free(t->name);
        free(t);
 }
 
@@ -239,8 +240,7 @@ struct task *task_register(struct task_info *info, struct sched *s)
        if (!s->task_list.next)
                INIT_LIST_HEAD(&s->task_list);
 
-       snprintf(t->name, sizeof(t->name) - 1, "%s", info->name);
-       t->name[sizeof(t->name) - 1] = '\0';
+       t->name = para_strdup(info->name);
        t->notification = 0;
        t->status = 0;
        t->dead = false;