aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/utils.c
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2013-08-06 15:07:47 +0200
committerPatrik Nyblom <[email protected]>2013-08-09 12:10:53 +0200
commit925d69c56d376d1e2371cd2236c981bc97ccb706 (patch)
tree08d7bab53db5b32818c86bb231d56fda8ef051d2 /erts/emulator/beam/utils.c
parent3e760de63ba212dd6e1e1de6d797202c60fcb26a (diff)
downloadotp-925d69c56d376d1e2371cd2236c981bc97ccb706.tar.gz
otp-925d69c56d376d1e2371cd2236c981bc97ccb706.tar.bz2
otp-925d69c56d376d1e2371cd2236c981bc97ccb706.zip
Clarify relation between erts_iolist_{size|to_buf}
Just some clarifying comments to future progremmers to keep the relation between error returns from the two functions.
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r--erts/emulator/beam/utils.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index 84deaecb87..c8695e61d5 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -3021,6 +3021,14 @@ buf_to_intlist(Eterm** hpp, char *buf, size_t len, Eterm tail)
** Return remaining bytes in buffer on success
** ERTS_IOLIST_TO_BUF_OVERFLOW on overflow
** ERTS_IOLIST_TO_BUF_TYPE_ERROR on type error (including that result would not be a whole number of bytes)
+**
+** Note!
+** Do not detect indata errors in this fiunction that are not detected by erts_iolist_size!
+**
+** A caller should be able to rely on a successful return from erts_iolist_to_buf
+** if erts_iolist_size is previously successfully called and erts_iolist_to_buf
+** is called with a buffer at least as large as the value given by erts_iolist_size.
+**
*/
ErlDrvSizeT erts_iolist_to_buf(Eterm obj, char* buf, ErlDrvSizeT alloced_len)
@@ -3127,6 +3135,11 @@ ErlDrvSizeT erts_iolist_to_buf(Eterm obj, char* buf, ErlDrvSizeT alloced_len)
/*
* Return 0 if successful, and non-zero if unsuccessful.
+ *
+ * It is vital that if erts_iolist_to_buf would return an error for
+ * any type of term data, this function should do so as well.
+ * Any input term error detected in erts_iolist_to_buf should also
+ * be detected in this function!
*/
int erts_iolist_size(Eterm obj, ErlDrvSizeT* sizep)
{