59 char padding[
sizeof(size_t) - 1];
63 char store[
sizeof(
char *) +
sizeof(
size_t) * 3 -
72 "corrupted agxbuf type");
104 return sizeof(xb->
u.
store);
137 nsize = size == 0 ? BUFSIZ : (2 * size);
138 if (size + ssz > nsize)
145 nbuf = (
char *)
gv_calloc(nsize,
sizeof(
char));
170 rc = vsnprintf(
NULL, 0, fmt, ap2);
176 size = (size_t)rc + 1;
182 if (unused_space < size) {
183 size_t extra = size - unused_space;
190 result = vsnprintf(dst, size, fmt, ap);
191 assert(result == (
int)(size - 1) || result < 0);
194 assert(result <= (
int)UCHAR_MAX);
195 xb->
u.
s.
located += (
unsigned char)result;
196 assert(
agxblen(xb) <=
sizeof(xb->
u.
store) &&
"agxbuf corruption");
198 xb->
u.
s.
size += (size_t)result;
207#define PRINTF_LIKE(index, first) __attribute__((format(printf, index, first)))
209#define PRINTF_LIKE(index, first)
238 assert(ssz <= UCHAR_MAX);
240 assert(
agxblen(xb) <=
sizeof(xb->
u.
store) &&
"agxbuf corruption");
250 size_t ssz = strlen(
s);
264 assert(
agxblen(xb) <=
sizeof(xb->
u.
store) &&
"agxbuf corruption");
314 memset(xb, 0,
sizeof(*xb));
341 for (period =
agxblen(xb) - 1;; --period) {
346 if (start[period] ==
'.') {
352 for (
size_t follower =
agxblen(xb) - 1;; --follower) {
353 if (follower == period || start[follower] ==
'0') {
361 if (follower == period) {
371 if (
len < 2 || start[
len - 2] !=
'-' || start[
len - 1] !=
'0') {
376 start[
len - 2] =
'0';
static int agxbpop(agxbuf *xb)
removes last character added, if any
static size_t agxbsizeof(const agxbuf *xb)
static void agxbuf_trim_zeros(agxbuf *xb)
static void agxbfree(agxbuf *xb)
free any malloced resources
static size_t agxbput(agxbuf *xb, const char *s)
append string s into xb
static size_t agxbput_n(agxbuf *xb, const char *s, size_t ssz)
append string s of length ssz into xb
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static char * agxbnext(agxbuf *xb)
next position for writing
static void agxbclear(agxbuf *xb)
resets pointer to data
static int vagxbprint(agxbuf *xb, const char *fmt, va_list ap)
vprintf-style output to an agxbuf
static void agxbmore(agxbuf *xb, size_t ssz)
expand buffer to hold at least ssz more bytes
static size_t agxblen(const agxbuf *xb)
return number of characters currently stored
static char * agxbstart(agxbuf *xb)
return pointer to beginning of buffer
static bool agxbuf_is_inline(const agxbuf *xb)
#define PRINTF_LIKE(index, first)
static int agxbputc(agxbuf *xb, char c)
add character to buffer
static char * agxbuse(agxbuf *xb)
static char * agxbdisown(agxbuf *xb)
agxbuf_loc_t
a description of where a buffer is located
Memory allocation wrappers that exit on failure.
static void * gv_recalloc(void *ptr, size_t old_nmemb, size_t new_nmemb, size_t size)
static void * gv_calloc(size_t nmemb, size_t size)
static char * gv_strndup(const char *original, size_t length)
static double len(glCompPoint p)
static int cnt(Dict_t *d, Dtlink_t **set)
static int store(segment_t *seg, int first, pointf *pts)
char store[sizeof(char *)+sizeof(size_t) *3 - 1]
char * buf
start of buffer
size_t size
number of characters in the buffer
struct agxbuf::@59::@60 s
unsigned char located
where does the backing memory for this buffer live?
size_t capacity
available bytes in the buffer