MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / alloc

Method alloc

src/yvalve/utl.cpp:3406–3427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3404 ThreadBuffer() : buffer_ptr(buffer) { }
3405
3406 const char* alloc(const char* string, size_t length)
3407 {
3408 // if string is already in our buffer - return it
3409 // it was already saved in our buffer once
3410 if (string >= buffer && string < &buffer[BUFFER_SIZE])
3411 return string;
3412
3413 // if string too long, truncate it
3414 if (length > BUFFER_SIZE / 4)
3415 length = BUFFER_SIZE / 4;
3416
3417 // If there isn't any more room in the buffer, start at the beginning again
3418 if (buffer_ptr + length + 1 > buffer + BUFFER_SIZE)
3419 buffer_ptr = buffer;
3420
3421 char* new_string = buffer_ptr;
3422 memcpy(new_string, string, length);
3423 new_string[length] = 0;
3424 buffer_ptr += length + 1;
3425
3426 return new_string;
3427 }
3428};
3429
3430TLS_DECLARE(ThreadBuffer*, threadBuffer);

Callers 1

circularAllocFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected