platform: read config file line by line

issue #2
This commit is contained in:
tylen
2024-09-25 20:49:31 +00:00
committed by Vasily Davydov
parent 62496e12c1
commit 807abee5f6
7 changed files with 87 additions and 9 deletions

View File

@@ -23,6 +23,15 @@ void buffer_append(Buffer* buffer, const char* str) {
buffer->size += len;
}
void buffer_append_c(Buffer* buffer, char c) {
if (buffer->size + 1 >= buffer->capacity) {
buffer->capacity *= 2;
buffer->data = (char*)cdo_realloc(buffer->data, buffer->capacity);
}
*(buffer->data + buffer->size) = c;
buffer->size++;
}
void buffer_flush(Buffer* buffer) {
printf("%s", buffer->data);
buffer_free(buffer);

View File

@@ -11,6 +11,7 @@ typedef struct {
Buffer* buffer_create(size_t capacity);
void buffer_append(Buffer* buffer, const char* str);
void buffer_append_c(Buffer* buffer, char c);
void buffer_flush(Buffer* buffer);
void buffer_free(Buffer* buffer);