odbx_result_finish(3)

πŸ’– odbx_result_finish(3) β€” the OpenDBX glow-up cleanup era ✨

okay bestie, this is a page from the OpenDBX manual and it's literally about the two functions that close out your result set and free its memory πŸŽ€ so like, the cleanup girlies. let's go 🫢

✨ SYNOPSIS ✨

#include <opendbx/api.h>

int odbx_result_finish (odbx_result_t* result);

void odbx_result_free (odbx_result_t* result);

that's it, that's the whole vibe check 🌸 two functions, one pointer, so many feelings.


πŸ’… NAME πŸ’…

odbx_result_finish, odbx_result_free β€” closes the result set and frees its allocated memory. yes both of them, they're a package deal πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

🌈 odbx_result_finish()

so odbx_result_finish() closes the result set β€” and lowkey that can even include dropping the non-fetched rows that the server sent πŸ‘€ like, it doesn't just tidy up, it may actually toss the leftovers.

it releases all resources allocated by odbx_result() and by the native database library that are attached to result, plus the memory that the first parameter is pointing to. all of it. every crumb 🧹✨

⚠️ ok this is the important part, bestie, listen: trying to free result manually with free() will create memory leaks 😭 because it contains more dynamically allocated structures, and also the memory of the result set allocated by the native database library. so like. don't. free() is not the moment, i promise.

and here's the thing that surprises people β€” odbx_result_finish() must be called even if the statement was not a SELECT-like statement which returned no rows 🫒 because it may be necessary to commit the changes done by the statement. no cap. a non-select statement still needs its finish. periodt πŸ’…

πŸŽ€ odbx_result_free()

odbx_result_free() performs the same tasks as odbx_result_finish() but it is unable to return an error if the task couldn't be completed πŸ™ˆ so if it fails you just... never know. iconic in a tragic way.

πŸ’€ it shouldn't be used in applications linking to the OpenDBX library version 1.3.8 or later and it will be removed from the library at a later stage. so she's giving deprecated, she's giving sunset era, she's giving "we don't stan anymore". use odbx_result_finish() instead, bestie 🫢

🌸 about result itself

result must be a valid result set created by odbx_result() which is returned via its second parameter. after feeding it to odbx_result_finish() it becomes invalid and must not be fed to it again πŸ”₯ otherwise a "double free" may occur and the application may be terminated 😭 like flat-out terminated, no thoughts head empty. so keep track of her, don't double-dip.


⭐ RETURN VALUE ⭐

odbx_result_finish() returns ODBX_ERR_SUCCESS, or an error code whose value is less than zero if one of the operations couldn't be completed successfully πŸ₯² possible error codes are listed in the error section (that's the next section, keep scrolling babe) and they can be fed to odbx_error() and odbx_error_type() to get further details πŸ”

(and odbx_result_free() returns... nothing. void. she says nothing and leaves πŸ’€)


πŸ“ ERRORS πŸ“

  • -ODBX_ERR_BACKEND β€” the native database library returned an error 😭 the backend said no ma'am
  • -ODBX_ERR_PARAM β€” the result parameter is invalid πŸ™ˆ wrong pointer, wrong era

πŸ‘‘ SEE ALSO πŸ‘‘

  • odbx_result() β€” the one that makes the result set in the first place ✨

and that's the page!! πŸ§šπŸ’œ this cutie was brought to you by the OpenDBX manual, dated 6 February 2026, and it's the odbx_result_finish(3) page in all her glory β€” clean your result sets, commit your statements, and never free() her manually πŸ’…πŸŽ€ bye bestie!! πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from