MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / jl_buffer_reserve

Function jl_buffer_reserve

src/cli/config_json_like.c:946–969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

944}
945
946static int jl_buffer_reserve(jl_buffer_t *buffer, size_t additional) {
947 if (additional > SIZE_MAX - buffer->length - 1U) {
948 return -1;
949 }
950 size_t needed = buffer->length + additional + 1U;
951 if (needed <= buffer->capacity) {
952 return 0;
953 }
954 size_t capacity = buffer->capacity ? buffer->capacity : 128U;
955 while (capacity < needed) {
956 if (capacity > SIZE_MAX / 2U) {
957 capacity = needed;
958 break;
959 }
960 capacity *= 2U;
961 }
962 char *grown = realloc(buffer->data, capacity);
963 if (!grown) {
964 return -1;
965 }
966 buffer->data = grown;
967 buffer->capacity = capacity;
968 return 0;
969}
970
971static int jl_buffer_append(jl_buffer_t *buffer, const char *data, size_t length) {
972 if (jl_buffer_reserve(buffer, length) != 0) {

Callers 1

jl_buffer_appendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected