| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "gate/results.h" | ||
| 2 | #include "gate/gate_sharedlib.h" | ||
| 3 | |||
| 4 | static void* stored_value = NULL; | ||
| 5 | static gate_size_t stored_value_length = 0; | ||
| 6 | |||
| 7 | ✗ | GATE_LIBARRY_LIB_INIT_PROTOTYPE | |
| 8 | { | ||
| 9 | ✗ | stored_value = NULL; | |
| 10 | ✗ | stored_value_length = 0; | |
| 11 | ✗ | return GATE_RESULT_OK; | |
| 12 | } | ||
| 13 | |||
| 14 | ✗ | GATE_LIBARRY_LIB_UNINIT_PROTOTYPE | |
| 15 | { | ||
| 16 | ✗ | if(stored_value != NULL) | |
| 17 | { | ||
| 18 | ✗ | gate_mem_dealloc(stored_value); | |
| 19 | } | ||
| 20 | ✗ | return GATE_RESULT_OK; | |
| 21 | } | ||
| 22 | |||
| 23 | ✗ | GATE_LIBARRY_LIB_GET_INFO_PROTOTYPE | |
| 24 | { | ||
| 25 | ✗ | return GATE_RESULT_NOTSUPPORTED; | |
| 26 | } | ||
| 27 | |||
| 28 | ✗ | GATE_LIBARRY_LIB_CREATE_OBJECT_PROTOTYPE | |
| 29 | { | ||
| 30 | ✗ | return GATE_RESULT_NOMATCH; | |
| 31 | } | ||
| 32 | |||
| 33 | |||
| 34 | ✗ | gate_result_t shared_lib_store_value(void const* ptr_value, gate_size_t length) | |
| 35 | { | ||
| 36 | ✗ | gate_result_t ret = GATE_RESULT_OK; | |
| 37 | ✗ | if(stored_value != NULL) | |
| 38 | { | ||
| 39 | ✗ | gate_mem_dealloc(stored_value); | |
| 40 | } | ||
| 41 | ✗ | if(length == 0) | |
| 42 | { | ||
| 43 | ✗ | stored_value = NULL; | |
| 44 | ✗ | stored_value_length = 0; | |
| 45 | } | ||
| 46 | else | ||
| 47 | { | ||
| 48 | ✗ | stored_value = gate_mem_alloc(length); | |
| 49 | ✗ | if(stored_value != NULL) | |
| 50 | { | ||
| 51 | ✗ | gate_mem_copy(stored_value, ptr_value, length); | |
| 52 | ✗ | stored_value_length = length; | |
| 53 | } | ||
| 54 | else | ||
| 55 | { | ||
| 56 | ✗ | stored_value_length = 0; | |
| 57 | ✗ | ret = GATE_RESULT_OUTOFMEMORY; | |
| 58 | } | ||
| 59 | } | ||
| 60 | ✗ | return ret; | |
| 61 | } | ||
| 62 | |||
| 63 | ✗ | gate_result_t shared_lib_get_value(void const** ptr_value, gate_size_t* ptr_length) | |
| 64 | { | ||
| 65 | ✗ | if(ptr_value) | |
| 66 | { | ||
| 67 | ✗ | *ptr_value = stored_value; | |
| 68 | } | ||
| 69 | ✗ | if(ptr_length) | |
| 70 | { | ||
| 71 | ✗ | *ptr_length = stored_value_length; | |
| 72 | } | ||
| 73 | ✗ | return GATE_RESULT_OK; | |
| 74 | } | ||
| 75 |