From a2e56bf9a36f84e094067cf45d2f1f9dbd57f291 Mon Sep 17 00:00:00 2001 From: "Dr.Smile" Date: Sun, 2 May 2021 00:46:32 +0300 Subject: compare: fix compilation under MinGW Replace missing strndup() with its standard C equivalent and circumvent unimplemented second argument of mkdir(). --- compare/compare.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compare/compare.c b/compare/compare.c index b93aef7..24d7829 100644 --- a/compare/compare.c +++ b/compare/compare.c @@ -23,6 +23,10 @@ #include #include +#if defined(_WIN32) && !defined(__CYGWIN__) +#define mkdir(path, mode) _mkdir(path) +#endif + #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) @@ -407,9 +411,11 @@ static bool add_sub_item(ItemList *list, const char *file, size_t len) return false; Item *item = &list->items[list->n_items]; - item->name = strndup(file, len); + item->name = malloc(len + 1); if (!item->name) return out_of_memory(); + memcpy(item->name, file, len); + item->name[len] = '\0'; item->time = -1; list->n_items++; return true; -- cgit v1.2.3