1 | // Copyright (c) Microsoft. All rights reserved.
|
---|
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
---|
3 |
|
---|
4 | #ifndef CONSTBUFFER_H
|
---|
5 | #define CONSTBUFFER_H
|
---|
6 |
|
---|
7 | #include "azure_c_shared_utility/buffer_.h"
|
---|
8 |
|
---|
9 | #ifdef __cplusplus
|
---|
10 | #include <cstddef>
|
---|
11 | extern "C"
|
---|
12 | {
|
---|
13 | #else
|
---|
14 | #include <stddef.h>
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #include "azure_c_shared_utility/umock_c_prod.h"
|
---|
18 |
|
---|
19 | /*this is the handle*/
|
---|
20 | typedef struct CONSTBUFFER_HANDLE_DATA_TAG* CONSTBUFFER_HANDLE;
|
---|
21 |
|
---|
22 | /*this is what is returned when the content of the buffer needs access*/
|
---|
23 | typedef struct CONSTBUFFER_TAG
|
---|
24 | {
|
---|
25 | const unsigned char* buffer;
|
---|
26 | size_t size;
|
---|
27 | } CONSTBUFFER;
|
---|
28 |
|
---|
29 | typedef void(*CONSTBUFFER_CUSTOM_FREE_FUNC)(void* context);
|
---|
30 |
|
---|
31 | /*this creates a new constbuffer from a memory area*/
|
---|
32 | MOCKABLE_FUNCTION(, CONSTBUFFER_HANDLE, CONSTBUFFER_Create, const unsigned char*, source, size_t, size);
|
---|
33 |
|
---|
34 | /*this creates a new constbuffer from an existing BUFFER_HANDLE*/
|
---|
35 | MOCKABLE_FUNCTION(, CONSTBUFFER_HANDLE, CONSTBUFFER_CreateFromBuffer, BUFFER_HANDLE, buffer);
|
---|
36 |
|
---|
37 | MOCKABLE_FUNCTION(, CONSTBUFFER_HANDLE, CONSTBUFFER_CreateWithMoveMemory, unsigned char*, source, size_t, size);
|
---|
38 |
|
---|
39 | MOCKABLE_FUNCTION(, CONSTBUFFER_HANDLE, CONSTBUFFER_CreateWithCustomFree, const unsigned char*, source, size_t, size, CONSTBUFFER_CUSTOM_FREE_FUNC, customFreeFunc, void*, customFreeFuncContext);
|
---|
40 |
|
---|
41 | MOCKABLE_FUNCTION(, void, CONSTBUFFER_IncRef, CONSTBUFFER_HANDLE, constbufferHandle);
|
---|
42 |
|
---|
43 | MOCKABLE_FUNCTION(, void, CONSTBUFFER_DecRef, CONSTBUFFER_HANDLE, constbufferHandle);
|
---|
44 |
|
---|
45 | MOCKABLE_FUNCTION(, const CONSTBUFFER*, CONSTBUFFER_GetContent, CONSTBUFFER_HANDLE, constbufferHandle);
|
---|
46 |
|
---|
47 | #ifdef __cplusplus
|
---|
48 | }
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | #endif /* CONSTBUFFER_H */
|
---|