I need an open lightweight (preferably MIT-licensed) lightweight growing buffer implemented in simple C (preferably also compiled as C ++).
I need an API equivalent to the following (pseudocode):
void set_allocator(buffer * buf, allocator_Fn fn);void push_bytes(buffer * buf, const char * bytes, size_t len);size_t get_length(buffer * buf);void overwrite_autogrow(buffer * buf, size_t offset, const char * bytes, size_t len);const char * to_string(buffer * buf);
Implementation should be clean and self-contained.
overwrite_autogrowwrites lenfrom bytesto a given offset with a growing buffer as necessary (as it does push_bytes).
The ability to install a distributor is optional, but preferable to have one.
Does anyone know something close to what I want?
Or, at least, any implementations that you should pay attention to when implementing my own?
source
share