Skip to content

Commit

Permalink
Changed __builtin_choose_expr to ternary expression to allow dynamic-…
Browse files Browse the repository at this point in the history
…length array types
  • Loading branch information
Snaipe committed Jun 8, 2015
1 parent 64c73a1 commit 44e6737
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions include/csptr/smart_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ inline void sfree_stack(void *ptr) {
Args \
}; \
const __typeof__(Type[1]) dummy; \
void *var = \
__builtin_choose_expr(sizeof (dummy[0]) == sizeof (dummy), \
smalloc(sizeof (Type), 0, Kind, ARGS_), \
smalloc(sizeof (dummy[0]), \
sizeof (dummy) / sizeof (dummy[0]), Kind, ARGS_)); \
void *var = sizeof (dummy[0]) == sizeof (dummy) \
? smalloc(sizeof (Type), 0, Kind, ARGS_) \
: smalloc(sizeof (dummy[0]), \
sizeof (dummy) / sizeof (dummy[0]), Kind, ARGS_); \
if (var != NULL) \
memcpy(var, &args.value, sizeof (Type)); \
var; \
Expand Down

0 comments on commit 44e6737

Please sign in to comment.