Next: , Previous: Autostr status, Up: Automatic strings


10.4 Copying into an automatic string

— Function: int astr_copy (Autostr *dest, const Autostr *src)

Sets the contents of dest to be a copy of the contents of src. Returns 0 if the function succeeded, or -1 if there was insufficient memory.

— Function: int astr_copy_s (Autostr *astr, const char *chars)

Sets the contents of astr to be a copy of the characters referenced by chars. Returns 0 if the function succeeded, or -1 if there was insufficient memory.

— Function: int astr_copy_c (Autostr *astr, c)

Sets the contents of astr to be c (converted to a ‘char’). c may not be zero. Returns 0 if the function succeeded, or -1 if there was insufficient memory.

— Function: int astr_copy_from_abuf (Autostr *astr, const Autobuf *ab)

Sets the contents of astr to be a copy of the textual portions of the data in ab. Every byte in ab is copied except for null bytes. Returns 0 if the function succeeded, or -1 if there was insufficient memory.

Note that this function has a different naming convention from that of the other ‘astr_copy...’ functions. This is because a conversion from autobuf to autostr to autobuf is lossy.