From ada68736474b42bffe5d8b4b2b2a4d67c738f95c Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Fri, 5 Aug 2022 13:51:09 -0300 Subject: git: Make use of `format_len()` in `dir_path_name()` --- misc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/misc.c b/misc.c index 75afc20..7c02291 100644 --- a/misc.c +++ b/misc.c @@ -133,10 +133,8 @@ char *dir_path_num(const char *root, int num) { char *dir_path_name(const char *root, char *name) { if (!is_empty(root)) { if (!is_empty(name)) { - /* Get the length of the path. */ - int len = snprintf(NULL, 0, "%s/%s", root, name); /* Create the directory path. */ - char *dir = calloc(len+1, sizeof(char)); + char *dir = calloc(format_len("%s/%s", root, name)+1, sizeof(char)); sprintf(dir, "%s/%s", root, name); return dir; } else { -- cgit v1.2.3-13-gbd6f