changeset 57:d77cd888a2f2

We should say something about how to return from the bulk function.
author Sjoerd Mullender <sjoerd@acm.org>
date Thu, 24 Mar 2022 18:37:39 +0100 (2022-03-24)
parents 8122094c79b1
children 02895996506d
files reverse/README.rst
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/reverse/README.rst	Wed Jan 26 15:07:02 2022 +0100
+++ b/reverse/README.rst	Thu Mar 24 18:37:39 2022 +0100
@@ -437,6 +437,26 @@
 as best it can.  That is why in the example we didn't need to do
 anything with the property flags.
 
+Returning the Result
+--------------------
+
+When the return BAT has been created and filled, it needs to be
+returned.  This is done by assigning the BAT id to the space the result
+pointer points to.  In addition, we need to deal with the reference
+counting mentioned before.  The input BAT's reference that we got from
+``BATdescriptor`` should be released with ``BBPunfix`` and one physical
+reference to the new BAT needs to be converted to one logical reference.
+This is done by a call to BBPkeepref.  And finally, the function should
+return and indicate that no errors occurred.  This is done by returning
+the value ``MAL_SUCCEED`` (which is just a ``NULL`` pointer).
+
+.. code-block:: c
+
+  BBPunfix(b->batCacheid);
+  BBPkeepref(bn->batCacheid);
+  *retval = bn->batCacheid;
+  return MAL_SUCCEED;
+
 Informing the Server
 --------------------