Skip to content

Commit

Permalink
Merge pull request #2134 from masatake/make-ptrArrayRemoveLast-return…
Browse files Browse the repository at this point in the history
…-the-removing-item

main: make ptrArrayRemoveLast return the removing item
  • Loading branch information
masatake committed Jul 8, 2019
2 parents 5b25693 + 83463ee commit 1258adf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion main/ptrarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ extern void ptrArrayAdd (ptrArray *const current, void *ptr)
current->array [current->count++] = ptr;
}

extern void ptrArrayRemoveLast (ptrArray *const current)
extern void *ptrArrayRemoveLast (ptrArray *const current)
{
Assert (current != NULL);
Assert (current->count > 0);
void *r = ptrArrayLast (current);
--current->count;
return r;
}

/* Combine array `from' into `current', deleting `from' */
Expand Down
2 changes: 1 addition & 1 deletion main/ptrarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef void (*ptrArrayDeleteFunc) (void *data);

extern ptrArray *ptrArrayNew (ptrArrayDeleteFunc deleteFunc);
extern void ptrArrayAdd (ptrArray *const current, void *ptr);
extern void ptrArrayRemoveLast (ptrArray *const current);
extern void *ptrArrayRemoveLast (ptrArray *const current);
extern void ptrArrayCombine (ptrArray *const current, ptrArray *const from);
extern void ptrArrayClear (ptrArray *const current);
extern unsigned int ptrArrayCount (const ptrArray *const current);
Expand Down

0 comments on commit 1258adf

Please sign in to comment.