Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Apr 28, 2023
1 parent 2bb48d8 commit 83a4709
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 321 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ set(SRCS
src/dns/rr.c
src/dns/rrlist.c

src/fmt/arg.c
src/fmt/ch.c
src/fmt/hexdump.c
src/fmt/pl.c
Expand Down
16 changes: 0 additions & 16 deletions include/re_fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,3 @@ int utf8_encode(struct re_printf *pf, const char *str);
int utf8_decode(struct re_printf *pf, const struct pl *pl);
size_t utf8_byteseq(char u[4], unsigned cp);


/* RE_VA_ARG - use only within RE_VA_ARG wrapped functions */
int re_va_arg_int(va_list *ap, bool type_check);
char *re_va_arg_char_p(va_list *ap, bool type_check);
const char *re_va_arg_const_char_p(va_list *ap, bool type_check);
size_t re_va_arg_size_t(va_list *ap, bool type_check);
ssize_t re_va_arg_ssize_t(va_list *ap, bool type_check);
signed long long re_va_arg_signed_long_long(va_list *ap, bool type_check);
signed long re_va_arg_signed_long(va_list *ap, bool type_check);
signed re_va_arg_signed(va_list *ap, bool type_check);
unsigned long long re_va_arg_unsigned_long_long(va_list *ap, bool type_check);
unsigned long re_va_arg_unsigned_long(va_list *ap, bool type_check);
unsigned re_va_arg_unsigned(va_list *ap, bool type_check);
double re_va_arg_double(va_list *ap, bool type_check);
void *re_va_arg_void_p(va_list *ap, bool type_check);
re_printf_h *re_va_arg_re_printf_h(va_list *ap, bool type_check);
13 changes: 13 additions & 0 deletions include/re_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,16 @@ typedef int re_sock_t;
#define RE_ARG_N2(N, ...) RE_ARG_N3(N, __VA_ARGS__)
#define RE_VA_ARGS(...) RE_ARG_N2(RE_ARG_VA_NUM(__VA_ARGS__), __VA_ARGS__)
#endif

#define RE_VA_ARG(ap, val, type, safe) \
if ((safe)) { \
size_t sz = va_arg((ap), size_t); \
assert(sz && "RE_VA_ARG: no more arguments"); \
assert(sz <= sizeof(type) && \
"RE_VA_ARG: arg is not compatible"); \
if (!sz || sz > sizeof(type)) { \
err = EINVAL; \
goto out; \
} \
} \
(val) = va_arg((ap), type)
267 changes: 0 additions & 267 deletions src/fmt/arg.c

This file was deleted.

Loading

0 comments on commit 83a4709

Please sign in to comment.