File Coverage

lib/SPVM/Builder/src/spvm_api_string_buffer.c
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 18 18 100.0


line stmt bran cond sub pod time code
1             // Copyright (c) 2023 Yuki Kimoto
2             // MIT License
3              
4             #include
5              
6             #include "spvm_native.h"
7              
8             #include "spvm_api_string_buffer.h"
9              
10             #include "spvm_allocator.h"
11             #include "spvm_string_buffer.h"
12              
13 119195           SPVM_API_STRING_BUFFER* SPVM_API_STRING_BUFFER_new_api() {
14 119195           void* env_string_buffer_init[] = {
15             SPVM_API_STRING_BUFFER_new_instance,
16             SPVM_API_STRING_BUFFER_free_instance,
17             SPVM_API_STRING_BUFFER_get_string,
18             SPVM_API_STRING_BUFFER_get_length,
19             };
20 119195           SPVM_API_STRING_BUFFER* env_string_buffer = calloc(1, sizeof(env_string_buffer_init));
21 119195           memcpy(env_string_buffer, env_string_buffer_init, sizeof(env_string_buffer_init));
22            
23 119195           return env_string_buffer;
24             }
25              
26 515           SPVM_STRING_BUFFER* SPVM_API_STRING_BUFFER_new_instance(SPVM_ALLOCATOR* allocator, int32_t capacity) {
27 515           SPVM_STRING_BUFFER* string_buffer = SPVM_STRING_BUFFER_new_tmp(allocator, capacity);
28            
29 515           return string_buffer;
30             }
31              
32 515           const char* SPVM_API_STRING_BUFFER_get_string(SPVM_STRING_BUFFER* string_buffer) {
33 515           return string_buffer->string;
34             }
35              
36 515           int32_t SPVM_API_STRING_BUFFER_get_length(SPVM_STRING_BUFFER* string_buffer) {
37 515           return string_buffer->length;
38             }
39              
40 515           void SPVM_API_STRING_BUFFER_free_instance(SPVM_STRING_BUFFER* string_buffer) {
41 515           SPVM_STRING_BUFFER_free(string_buffer);
42 515           }
43              
44 119195           void SPVM_API_STRING_BUFFER_free_api(SPVM_API_STRING_BUFFER* api) {
45 119195           free(api);
46 119195           }