51Degrees Common C/C++  4.1

A shared functionality library that is used by 51Degrees products

data.h

1 /* *********************************************************************
2  * This Source Code Form is copyright of 51 Degrees Mobile Experts Limited.
3  * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4  * Caversham, Reading, Berkshire, United Kingdom RG4 7BY
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0.
8  *
9  * If a copy of the MPL was not distributed with this file, You can obtain
10  * one at http://mozilla.org/MPL/2.0/.
11  *
12  * This Source Code Form is "Incompatible With Secondary Licenses", as
13  * defined by the Mozilla Public License, v. 2.0.
14  * ******************************************************************** */
15 
16 #ifndef FIFTYONE_DEGREES_DATA_H_INCLUDED
17 #define FIFTYONE_DEGREES_DATA_H_INCLUDED
18 
81 #include <stdint.h>
82 #include <stddef.h>
83 
84 #ifdef __cplusplus
85 #define EXTERNAL extern "C"
86 #else
87 #define EXTERNAL
88 #endif
89 
93 typedef unsigned char byte;
94 
99 typedef struct fiftyone_degrees_data_t {
100  byte *ptr;
101  uint32_t allocated;
104  uint32_t used;
106 
112 EXTERNAL void fiftyoneDegreesDataReset(fiftyoneDegreesData *data);
113 
122 EXTERNAL void* fiftyoneDegreesDataMalloc(
123  fiftyoneDegreesData *data,
124  size_t bytesNeeded);
125 
129 #endif
EXTERNAL void fiftyoneDegreesDataReset(fiftyoneDegreesData *data)
Resets the data structure ready for a new operation.
Definition: data.c:20
uint32_t used
Number of valid bytes currently referenced by pointer.
Definition: data.h:104
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition: data.h:99
byte * ptr
Pointer to immutable data.
Definition: data.h:100
uint32_t allocated
Number of bytes allocated at the pointer.
Definition: data.h:101
EXTERNAL void * fiftyoneDegreesDataMalloc(fiftyoneDegreesData *data, size_t bytesNeeded)
Ensures the data structure contains sufficient bytes.
Definition: data.c:26
unsigned char byte
Alias for unsigned char.
Definition: data.h:93