From 7a2e1a0a7a575c64eaf050c8ec08e5b36e4acfad Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 8 Apr 2021 12:04:33 +0200 Subject: Fix: libsquashfs: add sqfs_free() function On systems like Windows, the dynamic library and applications can easily end up being linked against different runtime libraries, so applications cannot be expected to be able to free() any malloc'd pointer that the library returns. This commit adds an sqfs_free function so the application can pass pointers back to the library to call the correct free() implementation. Signed-off-by: David Oberhollenzer --- lib/sqfs/Makemodule.am | 1 + lib/sqfs/misc.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 lib/sqfs/misc.c (limited to 'lib') diff --git a/lib/sqfs/Makemodule.am b/lib/sqfs/Makemodule.am index fedb7a8..99f06e9 100644 --- a/lib/sqfs/Makemodule.am +++ b/lib/sqfs/Makemodule.am @@ -29,6 +29,7 @@ libsquashfs_la_SOURCES += lib/sqfs/block_processor/common.c libsquashfs_la_SOURCES += lib/sqfs/block_processor/frontend.c libsquashfs_la_SOURCES += lib/sqfs/frag_table.c include/sqfs/frag_table.h libsquashfs_la_SOURCES += lib/sqfs/block_writer.c include/sqfs/block_writer.h +libsquashfs_la_SOURCES += lib/sqfs/misc.c libsquashfs_la_CPPFLAGS = $(AM_CPPFLAGS) libsquashfs_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBSQUASHFS_SO_VERSION) libsquashfs_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS) diff --git a/lib/sqfs/misc.c b/lib/sqfs/misc.c new file mode 100644 index 0000000..74a4203 --- /dev/null +++ b/lib/sqfs/misc.c @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: LGPL-3.0-or-later */ +/* + * misc.c + * + * Copyright (C) 2021 David Oberhollenzer + */ +#define SQFS_BUILDING_DLL +#include "config.h" + +#include "sqfs/predef.h" + +#include + +void sqfs_free(void *ptr) +{ + free(ptr); +} -- cgit v1.2.3