summaryrefslogtreecommitdiffstats
path: root/depends/lzma/wrapper/common_internal.c
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-09-26 02:58:09 +0200
committerPetr Mrázek <peterix@gmail.com>2013-09-26 02:59:56 +0200
commit2c8dc0b855c38c5204d398ad306fa9cf43be1ada (patch)
tree59429d658012a3df0e548e1a5f08100fb2930fc0 /depends/lzma/wrapper/common_internal.c
parentaf234f35029de8c46aefecd8b9345b30ae1c51b0 (diff)
downloadMultiMC-2c8dc0b855c38c5204d398ad306fa9cf43be1ada.tar
MultiMC-2c8dc0b855c38c5204d398ad306fa9cf43be1ada.tar.gz
MultiMC-2c8dc0b855c38c5204d398ad306fa9cf43be1ada.tar.lz
MultiMC-2c8dc0b855c38c5204d398ad306fa9cf43be1ada.tar.xz
MultiMC-2c8dc0b855c38c5204d398ad306fa9cf43be1ada.zip
Compression algo dependencies, still need hackery...
Diffstat (limited to 'depends/lzma/wrapper/common_internal.c')
-rw-r--r--depends/lzma/wrapper/common_internal.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/depends/lzma/wrapper/common_internal.c b/depends/lzma/wrapper/common_internal.c
new file mode 100644
index 00000000..c9213ef4
--- /dev/null
+++ b/depends/lzma/wrapper/common_internal.c
@@ -0,0 +1,46 @@
+/*
+ * Written in 2009 by Lloyd Hilaiel
+ *
+ * License
+ *
+ * All the cruft you find here is public domain. You don't have to credit
+ * anyone to use this code, but my personal request is that you mention
+ * Igor Pavlov for his hard, high quality work.
+ */
+
+#include "common_internal.h"
+
+static void *elzmaAlloc(void *p, size_t size)
+{
+ struct elzma_alloc_struct *as = (struct elzma_alloc_struct *)p;
+ if (as->clientMallocFunc)
+ {
+ return as->clientMallocFunc(as->clientMallocContext, size);
+ }
+ return malloc(size);
+}
+
+static void elzmaFree(void *p, void *address)
+{
+ struct elzma_alloc_struct *as = (struct elzma_alloc_struct *)p;
+ if (as->clientFreeFunc)
+ {
+ as->clientFreeFunc(as->clientMallocContext, address);
+ }
+ else
+ {
+ free(address);
+ }
+}
+
+void init_alloc_struct(struct elzma_alloc_struct *as, elzma_malloc clientMallocFunc,
+ void *clientMallocContext, elzma_free clientFreeFunc,
+ void *clientFreeContext)
+{
+ as->Alloc = elzmaAlloc;
+ as->Free = elzmaFree;
+ as->clientMallocFunc = clientMallocFunc;
+ as->clientMallocContext = clientMallocContext;
+ as->clientFreeFunc = clientFreeFunc;
+ as->clientFreeContext = clientFreeContext;
+}