Browse Source

Fix #18

Following PR #19
Yann Weber 5 years ago
parent
commit
0c4acf1fba
1 changed files with 1 additions and 5 deletions
  1. 1
    5
      src/ttail_init.c

+ 1
- 5
src/ttail_init.c View File

342
 
342
 
343
 int ttail_set_fmt(ttail_t* t, const char* fmt)
343
 int ttail_set_fmt(ttail_t* t, const char* fmt)
344
 {
344
 {
345
-	size_t len;
346
 	if(t->flag & TTAIL_FLAG_FORMAT)
345
 	if(t->flag & TTAIL_FLAG_FORMAT)
347
 	{
346
 	{
348
 		return -1;
347
 		return -1;
349
 	}
348
 	}
350
-	len = strlen(fmt);
351
-	t->fmt = malloc(sizeof(char)*(len+1));
349
+	t->fmt = strdup(fmt);
352
 	if(!t->fmt)
350
 	if(!t->fmt)
353
 	{
351
 	{
354
 		return -1;
352
 		return -1;
355
 	}
353
 	}
356
-	strncpy(t->fmt, fmt, len);
357
-	t->fmt[len] = '\0';
358
 	t->flag |= TTAIL_FLAG_FORMAT;
354
 	t->flag |= TTAIL_FLAG_FORMAT;
359
 	return 0;
355
 	return 0;
360
 }
356
 }

Loading…
Cancel
Save