<commit_before>#ifndef __BUFFER_H
#define __BUFFER_H

/* Create a static sized buffer. Writes past this size will simply not
   succeed. */
Buffer *buffer_create_static(Pool pool, size_t size);
/* Create a static sized buffer. Writes past this size will kill the program. */
Buffer *buffer_create_static_hard(Pool pool, size_t size);
/* Create a modifyable buffer from given data. */
Buffer *buffer_create_data(Pool pool, void *data, size_t size);
/* Create a non-modifyable buffer from given data. */
Buffer *buffer_create_const_data(Pool pool, const void *data, size_t size);
/* Creates a dynamically growing buffer. Whenever write would exceed the
   current size it's grown. */
Buffer *buffer_create_dynamic(Pool pool, size_t init_size, size_t max_size);
/* Free the memory used by buffer. Not needed if the memory is free'd
   directly from the memory pool. */
void buffer_free(Buffer *buf);
/* Free the memory used by buffer structure, but return the buffer data
   unfree'd.*/
void *buffer_free_without_data(Buffer *buf);

/* Write data to buffer at specified position, returns number of bytes
   written. */
size_t buffer_write(Buffer *buf, size_t pos,
		    const void *data, size_t data_size);
/* Append data to buffer, returns number of bytes written. */
size_t buffer_append(Buffer *buf, const void *data, size_t data_size);
/* Append character to buffer, returns 1 if written, 0 if not. */
size_t buffer_append_c(Buffer *buf, char chr);

/* Copy data from buffer to another. The buffers may be same in which case
   it's internal copying, possibly with overlapping positions (ie. memmove()
   like functionality). copy_size may be set to (size_t)-1 to copy the rest of
   the used data in buffer. Returns the number of bytes actually copied. */
size_t buffer_copy(Buffer *dest, size_t dest_pos,
		   const Buffer *src, size_t src_pos, size_t copy_size);
/* Append data to buffer from another. copy_size may be set to (size_t)-1 to
   copy the rest of the used data in buffer. */
size_t buffer_append_buf(Buffer *dest, const Buffer *src,
			 size_t src_pos, size_t copy_size);

/* Returns pointer to specified position in buffer, or NULL if there's not
   enough space. */
void *buffer_get_space(Buffer *buf, size_t pos, size_t size);
/* Increase the buffer usage by given size, and return a pointer to beginning
   of it, or NULL if there's not enough space in buffer. */
void *buffer_append_space(Buffer *buf, size_t size);<commit_msg>comment update<commit_after>#ifndef __BUFFER_H
#define __BUFFER_H

/* Create a static sized buffer. Writes past this size will simply not
   succeed. */
Buffer *buffer_create_static(Pool pool, size_t size);
/* Create a static sized buffer. Writes past this size will kill the program. */
Buffer *buffer_create_static_hard(Pool pool, size_t size);
/* Create a modifyable buffer from given data. */
Buffer *buffer_create_data(Pool pool, void *data, size_t size);
/* Create a non-modifyable buffer from given data. */
Buffer *buffer_create_const_data(Pool pool, const void *data, size_t size);
/* Creates a dynamically growing buffer. Whenever write would exceed the
   current size it's grown. */
Buffer *buffer_create_dynamic(Pool pool, size_t init_size, size_t max_size);
/* Free the memory used by buffer. Not needed if the memory is free'd
   directly from the memory pool. */
void buffer_free(Buffer *buf);
/* Free the memory used by buffer structure, but return the buffer data
   unfree'd. NOTE: Current start_pos doesn't affect the returned value. */
void *buffer_free_without_data(Buffer *buf);

/* Write data to buffer at specified position, returns number of bytes
   written. */
size_t buffer_write(Buffer *buf, size_t pos,
		    const void *data, size_t data_size);
/* Append data to buffer, returns number of bytes written. */
size_t buffer_append(Buffer *buf, const void *data, size_t data_size);
/* Append character to buffer, returns 1 if written, 0 if not. */
size_t buffer_append_c(Buffer *buf, char chr);

/* Copy data from buffer to another. The buffers may be same in which case
   it's internal copying, possibly with overlapping positions (ie. memmove()
   like functionality). copy_size may be set to (size_t)-1 to copy the rest of
   the used data in buffer. Returns the number of bytes actually copied. */
size_t buffer_copy(Buffer *dest, size_t dest_pos,
		   const Buffer *src, size_t src_pos, size_t copy_size);
/* Append data to buffer from another. copy_size may be set to (size_t)-1 to
   copy the rest of the used data in buffer. */
size_t buffer_append_buf(Buffer *dest, const Buffer *src,
			 size_t src_pos, size_t copy_size);

/* Returns pointer to specified position in buffer, or NULL if there's not
   enough space. */
void *buffer_get_space(Buffer *buf, size_t pos, size_t size);
/* Increase the buffer usage by given size, and return a pointer to beginning
   of it, or NULL if there's not enough space in buffer. */
void *buffer_append_space(Buffer *buf, size_t size);
{'fraction_non_alphanumeric': 0.08086307723331317, 'fraction_numerical': 0.001613228473482557, 'mean_word_length': 4.367965367965368, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '868384', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1416, 'n_words': 656}