| 1 |
/* |
| 2 |
* Copyright (C) 2014 Red Hat, Inc. |
| 3 |
* SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef __COCKPIT_MEMORY_H__ |
| 7 |
#define __COCKPIT_MEMORY_H__ |
| 8 |
|
| 9 |
#include <sys/types.h> |
| 10 |
|
| 11 |
void cockpit_memory_clear (void *data, |
| 12 |
ssize_t length); |
| 13 |
|
| 14 |
/* variants of glibc functions that abort() on ENOMEM */ |
| 15 |
void * mallocx (size_t size); |
| 16 |
void * callocx (size_t nmemb, size_t size); |
| 17 |
char * strdupx (const char *s); |
| 18 |
|
| 19 |
char * strndupx (const char *s, |
| 20 |
size_t n); |
| 21 |
|
| 22 |
__attribute__((__format__ (__printf__, 2, 3))) |
| 23 |
int asprintfx (char **strp, |
| 24 |
const char *fmt, ...); |
| 25 |
|
| 26 |
void * reallocx (void *ptr, |
| 27 |
size_t size); |
| 28 |
|
| 29 |
void * reallocarrayx (void *ptr, |
| 30 |
size_t nmemb, |
| 31 |
size_t size); |
| 32 |
|
| 33 |
#endif /* __COCKPIT_MEMORY_H__ */ |