Skip to content

Commit

Permalink
tevent: Add tevent_req_oom
Browse files Browse the repository at this point in the history
This is a replacement for tevent_req_nomem(NULL, req)
  • Loading branch information
vlendec committed Jun 20, 2011
1 parent 580fedc commit c2a826b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/tevent/tevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,20 @@ bool _tevent_req_nomem(const void *p,
_tevent_req_nomem(p, req, __location__)
#endif

#ifdef DOXYGEN
/**
* @brief Indicate out of memory to a request
*
* @param[in] req The request being processed.
*/
void tevent_req_oom(struct tevent_req *req);
#else
void _tevent_req_oom(struct tevent_req *req,
const char *location);
#define tevent_req_oom(req) \
_tevent_req_oom(req, __location__)
#endif

/**
* @brief Finish a request before the caller had the change to set the callback.
*
Expand Down
7 changes: 6 additions & 1 deletion lib/tevent/tevent_req.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,19 @@ bool _tevent_req_error(struct tevent_req *req,
return true;
}

void _tevent_req_oom(struct tevent_req *req, const char *location)
{
tevent_req_finish(req, TEVENT_REQ_NO_MEMORY, location);
}

bool _tevent_req_nomem(const void *p,
struct tevent_req *req,
const char *location)
{
if (p != NULL) {
return false;
}
tevent_req_finish(req, TEVENT_REQ_NO_MEMORY, location);
_tevent_req_oom(req, location);
return true;
}

Expand Down

0 comments on commit c2a826b

Please sign in to comment.