mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Reports the size of the allocated memory.
This commit is contained in:
parent
a0ad57d4f1
commit
4e2cb40f98
3 changed files with 16 additions and 0 deletions
2
state.c
2
state.c
|
|
@ -1009,6 +1009,8 @@ void state_read(struct snapraid_state* state)
|
|||
printf("\tblock %u\n", count_block);
|
||||
printf("\tsymlink %u\n", count_link);
|
||||
}
|
||||
|
||||
printf("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / 1024 / 1024));
|
||||
}
|
||||
|
||||
void state_write(struct snapraid_state* state)
|
||||
|
|
|
|||
9
util.c
9
util.c
|
|
@ -643,6 +643,13 @@ void pathslash(char* dst, size_t size)
|
|||
/****************************************************************************/
|
||||
/* mem */
|
||||
|
||||
static size_t mcounter;
|
||||
|
||||
size_t malloc_counter(void)
|
||||
{
|
||||
return mcounter;
|
||||
}
|
||||
|
||||
void* malloc_nofail(size_t size)
|
||||
{
|
||||
void* ptr = malloc(size);
|
||||
|
|
@ -652,6 +659,8 @@ void* malloc_nofail(size_t size)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
mcounter += size;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
5
util.h
5
util.h
|
|
@ -337,6 +337,11 @@ void pathslash(char* dst, size_t size);
|
|||
/****************************************************************************/
|
||||
/* memory */
|
||||
|
||||
/**
|
||||
* Return the size of the allocated memory.
|
||||
*/
|
||||
size_t malloc_counter(void);
|
||||
|
||||
/**
|
||||
* Safe malloc.
|
||||
* If no memory is available, it aborts.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue