Skip to content

Commit

Permalink
Check is allocation in event queue was success or not, and
Browse files Browse the repository at this point in the history
report error / assert when allocation fails.
  • Loading branch information
deepikabhavnani authored and geky committed Aug 4, 2019
1 parent 19ecc11 commit 4019f30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions equeue.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,18 +566,22 @@ static void equeue_chain_update(void *p, int ms) {
}
}

void equeue_chain(equeue_t *q, equeue_t *target) {
int equeue_chain(equeue_t *q, equeue_t *target) {
if (!target) {
equeue_background(q, 0, 0);
return;
return 0;
}

struct equeue_chain_context *c = equeue_alloc(q,
sizeof(struct equeue_chain_context));
if (!c) {
return -1;
}

c->q = q;
c->target = target;
c->id = 0;

equeue_background(q, equeue_chain_update, c);
return 0;
}
5 changes: 4 additions & 1 deletion equeue.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ void equeue_background(equeue_t *queue,
//
// The equeue_chain function allows multiple equeues to be composed, sharing
// the context of a dispatch loop while still being managed independently.
void equeue_chain(equeue_t *queue, equeue_t *target);
//
// If the event queue chaining fails, equeue_chain returns a negative,
// platform-specific error code.
int equeue_chain(equeue_t *queue, equeue_t *target);


#ifdef __cplusplus
Expand Down

0 comments on commit 4019f30

Please sign in to comment.