Merge pull request #30 from jmendeth/buffer-h

Some details at buffer
This commit is contained in:
Devin Torres 2013-10-08 08:54:33 -07:00
commit 8af2b139b7
2 changed files with 12 additions and 12 deletions

View file

@ -96,7 +96,7 @@ hoedown_buffer_puts(hoedown_buffer *buf, const char *str)
/* hoedown_buffer_putc: appends a single uint8_t to a buffer */
void
hoedown_buffer_putc(hoedown_buffer *buf, int c)
hoedown_buffer_putc(hoedown_buffer *buf, uint8_t c)
{
assert(buf && buf->unit);

View file

@ -23,7 +23,7 @@ typedef enum {
/* hoedown_buffer: character array buffer */
struct hoedown_buffer {
uint8_t *data; /* actual character data */
uint8_t *data; /* actual character data */
size_t size; /* size of the string */
size_t asize; /* allocated size (0 = volatile buffer) */
size_t unit; /* reallocation unit size (0 = read-only buffer) */
@ -36,37 +36,37 @@ typedef struct hoedown_buffer hoedown_buffer;
hoedown_buffer_put(output, literal, sizeof(literal) - 1)
/* hoedown_buffer_new: allocation of a new buffer */
hoedown_buffer *hoedown_buffer_new(size_t) __attribute__ ((malloc));
hoedown_buffer *hoedown_buffer_new(size_t unit) __attribute__ ((malloc));
/* hoedown_buffer_free: decrease the reference count and free the buffer if needed */
void hoedown_buffer_free(hoedown_buffer *);
void hoedown_buffer_free(hoedown_buffer *buf);
/* hoedown_buffer_reset: frees internal data of the buffer */
void hoedown_buffer_reset(hoedown_buffer *);
void hoedown_buffer_reset(hoedown_buffer *buf);
/* hoedown_buffer_grow: increasing the allocated size to the given value */
int hoedown_buffer_grow(hoedown_buffer *, size_t);
int hoedown_buffer_grow(hoedown_buffer *buf, size_t neosz);
/* hoedown_buffer_put: appends raw data to a buffer */
void hoedown_buffer_put(hoedown_buffer *, const void *, size_t);
void hoedown_buffer_put(hoedown_buffer *buf, const void *data, size_t len);
/* hoedown_buffer_puts: appends a NUL-terminated string to a buffer */
void hoedown_buffer_puts(hoedown_buffer *, const char *);
void hoedown_buffer_puts(hoedown_buffer *buf, const char *str);
/* hoedown_buffer_putc: appends a single char to a buffer */
void hoedown_buffer_putc(hoedown_buffer *, int);
void hoedown_buffer_putc(hoedown_buffer *buf, uint8_t c);
/* hoedown_buffer_prefix: compare the beginning of a buffer with a string */
int hoedown_buffer_prefix(const hoedown_buffer *buf, const char *prefix);
/* hoedown_buffer_slurp: removes a given number of bytes from the head of the array */
void hoedown_buffer_slurp(hoedown_buffer *, size_t);
void hoedown_buffer_slurp(hoedown_buffer *buf, size_t len);
/* hoedown_buffer_cstr: NUL-termination of the string array (making a C-string) */
const char *hoedown_buffer_cstr(hoedown_buffer *);
const char *hoedown_buffer_cstr(hoedown_buffer *buf);
/* hoedown_buffer_printf: formatted printing to a buffer */
void hoedown_buffer_printf(hoedown_buffer *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
void hoedown_buffer_printf(hoedown_buffer *buf, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
#ifdef __cplusplus
}