aboutsummaryrefslogtreecommitdiff
path: root/src/util/memory.h
blob: 55e8eace03a28e50afbf3f989ee4c1b384f7aacc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * ecgen, tool for generating Elliptic curve domain parameters
 * Copyright (C) 2017 J08nY
 */
/**
 * @file memory.h
 */
#ifndef ECGEN_MEMORY_H
#define ECGEN_MEMORY_H

#include <stddef.h>

/**
 * @brief Try mallocing some memory, exit(EXIT_FAILURE) if it fails.
 * @param size
 * @return
 */
void *try_malloc(size_t size);

/**
 * @brief Try callocing some memory, exit(EXIT_FAILURE) if it fails.
 * @param size
 * @return
 */
void *try_calloc(size_t size);

/**
 * @brief Try reallocing some memory, exit(EXIT_FAILURE) if it fails.
 * @param ptr
 * @param size
 * @return
 */
void *try_realloc(void *ptr, size_t size);

#endif  // ECGEN_MEMORY_H