Skip to content

Commit

Permalink
Merge pull request #913 from pguyot/w44/otp_socket-add-missing-comments
Browse files Browse the repository at this point in the history
Add missing comments on otp_socket function
  • Loading branch information
fadushin authored Oct 31, 2023
2 parents b44cc3b + 5a62f6b commit c061e15
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 c061e15

Please sign in to comment.