From: Andre Noll Date: Thu, 2 Jan 2014 01:16:33 +0000 (+0000) Subject: sched: Dont use fixed-size buffer for task names. X-Git-Tag: v0.5.3~8^2~5 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=69a294cd641c623db61f46ee86901845789a1c7b;ds=sidebyside sched: Dont use fixed-size buffer for task names. This is not more complicated than the strncpy(), and it allows for arbitrary long task names. --- diff --git a/sched.c b/sched.c index b92774fa..0a1cff28 100644 --- 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;