* \brief A buffer is a region of memory, together with a set of related
* subregions. Buffers are used for parsing and I/O operations.
*
- * The 'used region' and the 'available' region are disjoint, and their
+ * The 'used region' and the 'available region' are disjoint, and their
* union is the buffer's region. The used region extends from the beginning
* of the buffer region to the last used byte. The available region
* extends from one byte greater than the last used byte to the end of the
* 'consumed region' and the 'remaining region'. The union of these two
* regions is the used region. The consumed region extends from the beginning
* of the used region to the byte before the 'current' offset (if any). The
- * 'remaining' region the current pointer to the end of the used
+ * 'remaining' region extends from the current offset to the end of the used
* region. The size of the consumed region can be changed using various
* buffer commands. Initially, the consumed region is empty.
*
*
*\li 'b' is a valid buffer.
*
- *\li The length of the available region of 'b' is at least 1.
+ *\li The length of the remaining region of 'b' is at least 1.
*
* Ensures:
*
* Requires:
*\li 'b' is a valid buffer.
*
- *\li The length of the unused region of 'b' is at least 1
+ *\li The length of the available region of 'b' is at least 1
* or the buffer has autoreallocation enabled.
*
* Ensures:
*
*\li 'b' is a valid buffer.
*
- *\li The length of the available region of 'b' is at least 2
- * or the buffer has autoreallocation enabled.
+ *\li The length of the remaining region of 'b' is at least 2.
*
* Ensures:
*
* Requires:
*\li 'b' is a valid buffer.
*
- *\li The length of the unused region of 'b' is at least 2
+ *\li The length of the available region of 'b' is at least 2
* or the buffer has autoreallocation enabled.
*
* Ensures:
*
*\li 'b' is a valid buffer.
*
- *\li The length of the available region of 'b' is at least 4.
+ *\li The length of the remaining region of 'b' is at least 4.
*
* Ensures:
*
* Requires:
*\li 'b' is a valid buffer.
*
- *\li The length of the unused region of 'b' is at least 4
+ *\li The length of the available region of 'b' is at least 4
* or the buffer has autoreallocation enabled.
*
* Ensures:
*
*\li 'b' is a valid buffer.
*
- *\li The length of the available region of 'b' is at least 6.
+ *\li The length of the remaining region of 'b' is at least 6.
*
* Ensures:
*
* Requires:
*\li 'b' is a valid buffer.
*
- *\li The length of the unused region of 'b' is at least 6
+ *\li The length of the available region of 'b' is at least 6
* or the buffer has autoreallocation enabled.
*
* Ensures:
* Requires:
*\li 'b' is a valid buffer.
*
- * The length of the unused region of 'b' is at least 3
+ *\li The length of the available region of 'b' is at least 3
* or the buffer has autoreallocation enabled.
*
* Ensures:
* \brief Copy 'length' bytes of memory at 'base' into 'b'.
*
* Requires:
- *\li 'b' is a valid buffer, and it has at least 'length'
- * or the buffer has autoreallocation enabled.
+ *\li 'b' is a valid buffer.
*
*\li 'base' points to 'length' bytes of valid memory.
*
+ *\li The length of the available region of 'b' is at least 'length'
+ * or the buffer has autoreallocation enabled.
+ *
+ * Ensures:
+ *\li The used pointer in 'b' is advanced by 'length'.
*/
void
* Requires:
*\li 'b' is a valid buffer.
*
- *\li 'source' to be a valid NULL terminated string.
+ *\li 'source' is a valid NULL terminated string.
+ *
+ *\li The length of the available region of 'b' is at least strlen('source')
+ * or the buffer has autoreallocation enabled.
*
- *\li strlen(source) <= isc_buffer_available(b) || b->mctx != NULL
+ * Ensures:
+ *\li The used pointer in 'b' is advanced by strlen('source').
*/
void
* Requires:
*\li 'b' is a valid buffer.
*
- *\li strlen(dec(v)) <= isc_buffer_available(b) || b->mctx != NULL
+ *\li The length of the available region of 'b' is at least strlen(dec('v'))
+ * or the buffer has autoreallocation enabled.
+ *
+ * Ensures:
+ *\li The used pointer in 'b' is advanced by strlen(dec('v')).
*/
isc_result_t
/*!<
* \brief Copy the contents of 'r' into 'b'.
*
+ * Notes:
+ *\li If 'b' has autoreallocation enabled, and the length of 'r' is greater
+ * than the length of the available region of 'b', 'b' is reallocated.
+ *
* Requires:
*\li 'b' is a valid buffer.
*
*\li 'r' is a valid region.
*
* Returns:
- *
*\li ISC_R_SUCCESS
*\li ISC_R_NOSPACE The available region of 'b' is not
* big enough.
isc_result_t
isc_buffer_dup(isc_mem_t *mctx, isc_buffer_t **dstp, const isc_buffer_t *src);
/*!<
- * \brief Allocate 'dst' and copy used contents of 'src' into it
+ * \brief Allocate 'dst' and copy used contents of 'src' into it.
*
* Requires:
- *\li 'dstp' is not NULL and *dst is NULL
+ *\li 'dstp' is not NULL and *dst is NULL.
*\li 'src' is a valid buffer.
*
* Returns:
- *
*\li ISC_R_SUCCESS
- *\li ISC_R_NOSPACE The available region of 'b' is not
- * big enough.
*/
isc_result_t
*\li The 'format' argument is a printf(3) string, with additional arguments
* as necessary.
*
- *\li If 'b' has autoreallocation enabled, and the formatted string
- * would overrun the buffer, the buffer is reallocated.
+ *\li If 'b' has autoreallocation enabled, and the length of the formatted
+ * string is greater than the length of the available region of 'b', 'b'
+ * is reallocated.
*
* Requires:
*