MCPcopy Create free account
hub / github.com/DeNA/HandlerSocket-Plugin-for-MySQL / reserve

Method reserve

libhsclient/string_buffer.hpp:52–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 end_offset = begin_offset + len;
51 }
52 void reserve(size_t len) {
53 if (alloc_size >= begin_offset + len) {
54 return;
55 }
56 size_t asz = alloc_size;
57 while (asz < begin_offset + len) {
58 if (asz == 0) {
59 asz = 16;
60 }
61 const size_t asz_n = asz << 1;
62 if (asz_n < asz) {
63 fatal_abort("string_buffer::resize() overflow");
64 }
65 asz = asz_n;
66 }
67 void *const p = DENA_REALLOC(buffer, asz);
68 if (p == 0) {
69 fatal_abort("string_buffer::resize() realloc");
70 }
71 buffer = static_cast<char *>(p);
72 alloc_size = asz;
73 }
74 void erase_front(size_t len) {
75 if (len >= size()) {
76 clear();

Callers

nothing calls this directly

Calls 1

fatal_abortFunction · 0.85

Tested by

no test coverage detected