The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

SPVM::Document::NativeAPI::StringBuffer - String Buffer Native APIs

Description

The string buffer native APIs in SPVM are the APIs for string buffers

Usage

  SPVM_API_STRING_BUFFER* string_buffer_api = env->api->string_buffer;
  
  SPVM_API_ALLOCATOR* api_allocator = env->api->allocator;
  
  void* allocator = api_allocator->new_instance();
  
  int32_t capacity = 100;
  
  void* string_buffer = string_buffer_api->new_instance(allocator, capacity);
  
  string_buffer_api->free_instance(string_buffer);
  
  api_allocator->free_instance(allocator);

Native APIs

new_instance

void* (*new_instance)(void* allocator, int32_t capacity);

Creates a new string buffer given its capacity capacity, and returns it.

free_instance

void (*free_instance)(void* string_buffer);

Frees the string buffer string_buffer.

get_string

const char* (*get_string)(void* string_buffer);

Returns the string stored in the string buffer string_buffer.

get_length

int32_t (*get_length)(void* string_buffer);

Returns the length of the string stored in the string buffer string_buffer.

Native API IDs

  0 new_instance
  1 free_instance
  2 get_string
  3 get_length

See Also

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License