diff --git a/libcustomntfs/source/cache.c b/libcustomntfs/source/cache.c index 2ad8d359..faabe628 100644 --- a/libcustomntfs/source/cache.c +++ b/libcustomntfs/source/cache.c @@ -280,7 +280,7 @@ struct CACHED_GENERIC *ntfs_enter_cache(struct CACHE_HEADER *cache, cache->oldest_entry = current->previous; if (item->varsize) { if (current->varsize) - current->variable = realloc( + current->variable = MEM2_realloc( current->variable, item->varsize); else diff --git a/libcustomntfs/source/index.c b/libcustomntfs/source/index.c index d498dde4..b0c0a4e6 100644 --- a/libcustomntfs/source/index.c +++ b/libcustomntfs/source/index.c @@ -1279,7 +1279,7 @@ static int ntfs_ie_add_vcn(INDEX_ENTRY **ie) INDEX_ENTRY *p, *old = *ie; old->length = cpu_to_le16(le16_to_cpu(old->length) + sizeof(VCN)); - p = realloc(old, le16_to_cpu(old->length)); + p = MEM2_realloc(old, le16_to_cpu(old->length)); if (!p) return STATUS_ERROR; diff --git a/libcustomntfs/source/lcnalloc.c b/libcustomntfs/source/lcnalloc.c index e84d2431..23bbb23d 100644 --- a/libcustomntfs/source/lcnalloc.c +++ b/libcustomntfs/source/lcnalloc.c @@ -356,7 +356,7 @@ runlist *ntfs_cluster_alloc(ntfs_volume *vol, VCN start_vcn, s64 count, /* Reallocate memory if necessary. */ if ((rlpos + 2) * (int)sizeof(runlist) >= rlsize) { rlsize += 4096; - trl = realloc(rl, rlsize); + trl = MEM2_realloc(rl, rlsize); if (!trl) { err = ENOMEM; ntfs_log_perror("realloc() failed"); diff --git a/libcustomntfs/source/mem_allocate.h b/libcustomntfs/source/mem_allocate.h index e15e367a..07681005 100644 --- a/libcustomntfs/source/mem_allocate.h +++ b/libcustomntfs/source/mem_allocate.h @@ -28,20 +28,12 @@ static inline void* ntfs_alloc (size_t size) { - #ifdef __wii__ return MEM2_alloc(size); - #else - return malloc(size); - #endif } static inline void* ntfs_align (size_t size) { - #ifdef __wii__ - return memalign(32, size); - #else - return malloc(size); - #endif + return MEM2_alloc(size); } static inline void ntfs_free (void* mem) diff --git a/libcustomntfs/source/misc.c b/libcustomntfs/source/misc.c index b2e17cbf..19209b92 100644 --- a/libcustomntfs/source/misc.c +++ b/libcustomntfs/source/misc.c @@ -34,6 +34,7 @@ #include "types.h" #include "misc.h" #include "logging.h" +#include "mem2.h" /** * ntfs_calloc @@ -44,7 +45,10 @@ void *ntfs_calloc(size_t size) { void *p; - p = calloc(1, size); + p = MEM2_alloc(size); + if(p) + memset(p, 0, size); + if (!p) ntfs_log_perror("Failed to calloc %lld bytes", (long long)size); return p; @@ -54,7 +58,7 @@ void *ntfs_malloc(size_t size) { void *p; - p = malloc(size); + p = MEM2_alloc(size); if (!p) ntfs_log_perror("Failed to malloc %lld bytes", (long long)size); return p; diff --git a/libcustomntfs/source/unistr.c b/libcustomntfs/source/unistr.c index 9a238014..419086ab 100644 --- a/libcustomntfs/source/unistr.c +++ b/libcustomntfs/source/unistr.c @@ -1011,7 +1011,7 @@ int ntfs_mbstoucs(const char *ins, ntfschar **outs) if (o >= ucs_len) { ntfschar *tc; ucs_len = (ucs_len * sizeof(ntfschar) + 64) & ~63; - tc = realloc(ucs, ucs_len); + tc = MEM2_realloc(ucs, ucs_len); if (!tc) goto err_out; ucs = tc;