Lines Matching refs:buf

55 struct Buf *buf_print_strings(struct Buf * buf, FILE* out)  in buf_print_strings()  argument
59 if(!buf || !out) in buf_print_strings()
60 return buf; in buf_print_strings()
62 for (i=0; i < buf->nelts; i++){ in buf_print_strings()
63 const char * s = ((char**)buf->elts)[i]; in buf_print_strings()
67 return buf; in buf_print_strings()
71 struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s) in buf_prints() argument
81 buf = buf_strappend (buf, t); in buf_prints()
83 return buf; in buf_prints()
92 struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno) in buf_linedir() argument
99 return buf; in buf_linedir()
114 buf = buf_strappend (buf, t); in buf_linedir()
116 return buf; in buf_linedir()
133 struct Buf *buf_strnappend (struct Buf *buf, const char *str, int n) in buf_strnappend() argument
135 buf_append (buf, str, n + 1); in buf_strnappend()
138 buf->nelts--; in buf_strnappend()
140 return buf; in buf_strnappend()
144 struct Buf *buf_strappend (struct Buf *buf, const char *str) in buf_strappend() argument
146 return buf_strnappend (buf, str, (int) strlen (str)); in buf_strappend()
150 struct Buf *buf_strdefine (struct Buf *buf, const char *str, const char *def) in buf_strdefine() argument
152 buf_strappend (buf, "#define "); in buf_strdefine()
153 buf_strappend (buf, " "); in buf_strdefine()
154 buf_strappend (buf, str); in buf_strdefine()
155 buf_strappend (buf, " "); in buf_strdefine()
156 buf_strappend (buf, def); in buf_strdefine()
157 buf_strappend (buf, "\n"); in buf_strdefine()
158 return buf; in buf_strdefine()
167 struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val) in buf_m4_define() argument
180 buf_append(buf, &str, 1); in buf_m4_define()
181 return buf; in buf_m4_define()
189 struct Buf *buf_m4_undefine (struct Buf *buf, const char* def) in buf_m4_undefine() argument
201 buf_append(buf, &str, 1); in buf_m4_undefine()
202 return buf; in buf_m4_undefine()
206 void buf_init (struct Buf *buf, size_t elem_size) in buf_init() argument
208 buf->elts = NULL; in buf_init()
209 buf->nelts = 0; in buf_init()
210 buf->elt_size = elem_size; in buf_init()
211 buf->nmax = 0; in buf_init()
215 void buf_destroy (struct Buf *buf) in buf_destroy() argument
217 if (buf) { in buf_destroy()
218 free(buf->elts); in buf_destroy()
219 buf->elts = NULL; in buf_destroy()
230 struct Buf *buf_append (struct Buf *buf, const void *ptr, int n_elem) in buf_append() argument
235 return buf; in buf_append()
238 if (n_elem + buf->nelts > buf->nmax) { in buf_append()
241 n_alloc = n_elem + buf->nelts; in buf_append()
244 if ((((size_t) n_alloc * buf->elt_size) % 512) != 0 in buf_append()
245 && buf->elt_size < 512) in buf_append()
248 (((size_t) n_alloc * buf->elt_size) % 512)) / in buf_append()
249 buf->elt_size); in buf_append()
251 if (!buf->elts) in buf_append()
252 buf->elts = in buf_append()
253 allocate_array ((int) n_alloc, buf->elt_size); in buf_append()
255 buf->elts = in buf_append()
256 reallocate_array (buf->elts, (int) n_alloc, in buf_append()
257 buf->elt_size); in buf_append()
259 buf->nmax = n_alloc; in buf_append()
262 memcpy ((char *) buf->elts + (size_t) buf->nelts * buf->elt_size, ptr, in buf_append()
263 (size_t) n_elem * buf->elt_size); in buf_append()
264 buf->nelts += n_elem; in buf_append()
266 return buf; in buf_append()