Skip to content

Commit

Permalink
Add missing comments on otp_socket function
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Guyot <[email protected]>
  • Loading branch information
pguyot committed Oct 31, 2023
1 parent b44cc3b commit 5a62f6b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/libAtomVM/otp_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,17 @@ static inline int get_protocol(GlobalContext *global, term protocol_term, bool *
}
}

/**
* @brief Allocate memory on ctx and make and return an error tuple from immediate
* term reason.
* @param reason the reason, should be an immediate (atom or integer)
* @param ctx the current context
* @returns a term
* @details This function is meant to be called from a nif that should return
* its result directly, to allow for further processing of a possible out of
* memory exception.
* @end
*/
static inline term make_error_tuple(term reason, Context *ctx)
{
if (UNLIKELY(memory_ensure_free(ctx, TUPLE_SIZE(2)) != MEMORY_GC_OK)) {
Expand All @@ -481,6 +492,9 @@ static inline term make_error_tuple(term reason, Context *ctx)
}

#if OTP_SOCKET_BSD
/**
* @brief Like make_error_tuple but using errno converted to an atom or an int
*/
static term make_errno_tuple(Context *ctx)
{
return make_error_tuple(posix_errno_to_term(errno, ctx->global), ctx);
Expand Down

0 comments on commit 5a62f6b

Please sign in to comment.