Next: , Previous: Autobuf concatenation, Up: Automatic buffers


11.6 Inserting into an autobuf

— Function: int abuf_insert (Autobuf *dest, ssize_t index, const Autobuf *src)

Inserts a copy of the contents of src into dest at position index. index must be non-negative and no greater than the length of dest. Returns 0 if the function succeeded, or -1 if there was insufficient memory.

— Function: int abuf_insert_buf (Autobuf *abuf, ssize_t index, const unsigned char *buf, ssize_t len)

Inserts a copy of the len bytes stored at buf into abuf at position index. len may not be negative. index must be non-negative and no greater than the length of abuf. Returns 0 if the function succeeded, or -1 if there was insufficient memory.

— Function: int abuf_insert_astr (Autobuf *abuf, ssize_t index, const Autostr *astr)

Inserts a copy of the contents of astr into abuf at position index. index must be non-negative and no greater than the length of dest. Returns 0 if the function succeeded, or -1 if there was insufficient memory.

— Function: int abuf_insert_s (Autobuf *abuf, ssize_t index, const char *chars)

Inserts a copy of the characters referenced by chars into abuf at position index. index must be non-negative and no greater than the length of abuf. Returns 0 if the function succeeded, or -1 if there was insufficient memory.

— Function: int abuf_insert_c (Autobuf *abuf, ssize_t index, int c)

Inserts c (converted to an ‘unsigned char’) into abuf at position index. index must be non-negative and no greater than the length of abuf. Returns 0 if the function succeeded, or -1 if there was insufficient memory.