lifting a portion of the strbuf api/implementation found in archived. This will serve as a base for an generic buffer api.