diff options
author | Vincent Douillet <vincent@vdouillet.fr> | 2024-01-12 18:14:17 +0100 |
---|---|---|
committer | Vincent Douillet <vincent@vdouillet.fr> | 2024-01-12 18:26:22 +0100 |
commit | 760031b4a74d70bdeaab4ce9aedfe772acd05bd3 (patch) | |
tree | 443a456770d5db052a3dfe3d2f1a8e5f66604ccb /util.c | |
parent | 43f65c76152017420ce723b4d4ef4230ff072818 (diff) |
browse: build download url for files
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "util.h" @@ -41,3 +42,21 @@ read_file(char *path, char **output, size_t * read_size) return 0; } + +char * +v_strcpy(char *str, size_t len) +{ + char *new_str; + size_t new_len; + + new_str = (char *) malloc(sizeof(char) * (len + 1)); + if (new_str == NULL) + return NULL; + + new_len = strlcpy(new_str, str, len + 1); + if (new_len >= len + 1) { + free(new_str); + return NULL; + } + return new_str; +} |