void o_string_buffer_append(struct o_string_buffer * buff, char * to_append) { int size = strlen(to_append); if (buff->cursor + size >= buff->size) { buff->size = buff->size * 2; buff->buffer = o_realloc(buff->buffer, buff->size); } memcpy(buff->buffer + buff->cursor, to_append, size); buff->cursor += size; }
void o_output_stream_byte_write_bytes(struct o_output_stream * stream, void *bytes, int nbytes) { struct o_output_stream_byte *buff = (struct o_output_stream_byte *) stream; if (buff->cursor + nbytes >= buff->size) { do { buff->size *= 2; } while (buff->cursor + nbytes >= buff->size); buff->content = o_realloc(buff->content, buff->size); } memcpy(buff->content + buff->cursor, bytes, nbytes); buff->cursor += nbytes; }