snapraid/cmdline/memory.h
Andrea Mazzoleni ca459e9fb0
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
Remove leading double underscores from header include guards
2026-10-13 11:20:19 +02:00

62 lines
1.2 KiB
C

// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2011 Andrea Mazzoleni
#ifndef MEMORY_H
#define MEMORY_H
/****************************************************************************/
/* memory */
/**
* Return the size of the cumulative allocated memory.
*/
size_t malloc_counter_get(void);
/**
* Enable or disable single-thread mode for memory counters.
*/
void memory_single_thread(int single_thread);
/**
* Safe malloc.
* If no memory is available, it aborts.
*/
void* malloc_nofail(size_t size);
/**
* Safe realloc.
* If no memory is available, it aborts.
*/
void* realloc_nofail(void* ptr, size_t size);
/**
* Safe malloc with calloc calling arguments.
* If no memory is available, it aborts.
*/
void* nalloc_nofail(size_t count, size_t size);
/**
* Safe calloc.
* If no memory is available, it aborts.
*/
void* calloc_nofail(size_t count, size_t size);
/**
* Safe strdup.
* If no memory is available, it aborts.
*/
char* strdup_nofail(const char* str);
/**
* Safe strndup with known length.
* If no memory is available, it aborts.
*/
char* strndup_nofail(const char* str, size_t size);
/**
* Helper for printing an error about a failed allocation.
*/
void malloc_fail(size_t size);
#endif