Defined ntfs_realloc() and ntfs_free()

Currently memory allocations are done through ntfs_malloc() and
ntfs_calloc(), but releases are done through free(3). Defining an
ntfs_free() relay facilitates the debugging of memory leaks in
plugins.
This commit is contained in:
Jean-Pierre André 2021-01-26 10:06:17 +01:00
parent 76fe04d03d
commit 8fa3dd3f22
2 changed files with 18 additions and 0 deletions

View File

@ -25,6 +25,8 @@
void *ntfs_calloc(size_t size);
void *ntfs_malloc(size_t size);
void *ntfs_realloc(void *ptr, size_t size);
void ntfs_free(void *ptr);
#endif /* _NTFS_MISC_H_ */

View File

@ -59,3 +59,19 @@ void *ntfs_malloc(size_t size)
ntfs_log_perror("Failed to malloc %lld bytes", (long long)size);
return p;
}
void *ntfs_realloc(void *ptr, size_t size)
{
void *p;
p = realloc(ptr, size);
if (!p)
ntfs_log_perror("Failed to realloc %lld bytes",
(long long)size);
return p;
}
void ntfs_free(void *p)
{
free(p);
}