libcbor  0.5.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
memory_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2017 Pavel Kalvoda <me@pavelkalvoda.com>
3  *
4  * libcbor is free software; you can redistribute it and/or modify
5  * it under the terms of the MIT license. See LICENSE for details.
6  */
7 
8 #ifndef LIBCBOR_MEMORY_UTILS_H
9 #define LIBCBOR_MEMORY_UTILS_H
10 
11 #include <string.h>
12 #include <stdbool.h>
13 
15 bool _cbor_safe_to_multiply(size_t a, size_t b);
16 
23 void * _cbor_alloc_multiple(size_t item_size, size_t item_count);
24 
25 
35 void * _cbor_realloc_multiple(void * pointer, size_t item_size, size_t item_count);
36 
37 #endif //LIBCBOR_MEMORY_UTILS_H
void * _cbor_realloc_multiple(void *pointer, size_t item_size, size_t item_count)
Overflow-proof contiguous array reallocation.
Definition: memory_utils.c:39
void * _cbor_alloc_multiple(size_t item_size, size_t item_count)
Overflow-proof contiguous array allocation.
Definition: memory_utils.c:30
bool _cbor_safe_to_multiply(size_t a, size_t b)
Can a and b be multiplied without overflowing size_t?
Definition: memory_utils.c:25