2 * Eddie Kohler, Yandong Mao, Robert Morris
3 * Copyright (c) 2012-2014 President and Fellows of Harvard College
4 * Copyright (c) 2012-2014 Massachusetts Institute of Technology
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, subject to the conditions
9 * listed in the Masstree LICENSE file. These conditions include: you must
10 * preserve this copyright notice, and you cannot mention the copyright
11 * holders in advertising related to the Software without their permission.
12 * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
13 * notice is a summary of the Masstree LICENSE file; the license in that file
27 unsigned capacity; // allocated size of buf
28 unsigned n; // # of chars we've written to buf
30 inline void append(char c);
31 inline char* reserve(int n);
32 inline void adjust_length(int delta);
33 inline void set_end(char* end);
34 void grow(unsigned want);
37 kvout* new_kvout(int fd, int buflen);
38 kvout* new_bufkvout();
39 void kvout_reset(kvout* kv);
40 void free_kvout(kvout* kv);
41 int kvwrite(kvout* kv, const void* buf, unsigned int n);
42 void kvflush(kvout* kv);
44 inline void kvout::append(char c) {
51 inline char* kvout::reserve(int nchars) {
52 if (n + nchars > capacity)
57 inline void kvout::adjust_length(int delta) {
58 masstree_precondition(n + delta <= capacity);
62 inline void kvout::set_end(char* x) {
63 masstree_precondition(x >= buf && x <= buf + capacity);