mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Reduces memory occupation with many files.
This commit is contained in:
parent
a41443b6b6
commit
b7bedc8b60
5 changed files with 43 additions and 3 deletions
22
util.c
22
util.c
|
|
@ -755,6 +755,28 @@ void* malloc_nofail_align(size_t size, void** freeptr)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
char* strdup_nofail(const char* str)
|
||||
{
|
||||
size_t size;
|
||||
char* ptr;
|
||||
|
||||
size = strlen(str) + 1;
|
||||
|
||||
ptr = malloc(size);
|
||||
|
||||
if (!ptr) {
|
||||
/* don't use printf to avoid any possible extra allocation */
|
||||
write(2, "Low Memory\n", 11);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
memcpy(ptr, str, size);
|
||||
|
||||
mcounter += size;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#include "murmurhash3.c"
|
||||
|
||||
void memhash(unsigned kind, void* digest, const void* src, unsigned size)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue