MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / _encode_string

Function _encode_string

compat/variant_decoder_compat.cpp:1888–1905  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1886}
1887
1888static void _encode_string(const String &p_string, uint8_t *&buf, int &r_len) {
1889 CharString utf8 = p_string.utf8();
1890
1891 if (buf) {
1892 encode_uint32(utf8.length(), buf);
1893 buf += 4;
1894 memcpy(buf, utf8.get_data(), utf8.length());
1895 buf += utf8.length();
1896 }
1897
1898 r_len += 4 + utf8.length();
1899 while (r_len % 4) {
1900 r_len++; //pad
1901 if (buf) {
1902 *(buf++) = 0;
1903 }
1904 }
1905}
1906
1907Error VariantDecoderCompat::encode_variant_3(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects, int p_depth) {
1908 ERR_FAIL_COND_V_MSG(p_depth > Variant::MAX_RECURSION_DEPTH, ERR_OUT_OF_MEMORY, "Potential infinite recursion detected. Bailing.");

Callers 2

encode_variant_3Method · 0.85
encode_variant_2Method · 0.85

Calls 2

lengthMethod · 0.80
get_dataMethod · 0.45

Tested by

no test coverage detected