Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change all va_list type argument to va_list* #90

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions append.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ char *append_pointer(char *dest, char *limit, PNT_ARITH_TYPE value, int base)
* characters added will be returned. No \0 character will be added.
*/
char *append_vformat(char *dest, char *limit, const char *format,
va_list args)
va_list *args)
{
const char *format_p = format;
char value_buf[64];
Expand Down Expand Up @@ -309,9 +309,9 @@ char *append_vformat(char *dest, char *limit, const char *format,
trunc = 1;
} else if (ch == '*') {
if (trunc) {
trunc_len = va_arg(args, int);
trunc_len = va_arg(*args, int);
} else {
width_len = va_arg(args, int);
width_len = va_arg(*args, int);
}
} else if (ch >= '0' && ch <= '9') {
if (trunc) {
Expand All @@ -338,20 +338,20 @@ char *append_vformat(char *dest, char *limit, const char *format,

const char *value;
if (ch == 'c') {
value_buf[0] = (char)va_arg(args, int);
value_buf[0] = (char)va_arg(*args, int);
value_buf[1] = '\0';
value = value_buf;
} else if (ch == 'd') {
long num;
if (long_arg) {
num = va_arg(args, long);
num = va_arg(*args, long);
} else {
num = va_arg(args, int);
num = va_arg(*args, int);
}
handle_decimal(value_buf, value_limit, num, 10);
value = value_buf;
} else if (ch == 'f') {
double num = va_arg(args, double);
double num = va_arg(*args, double);
if (trunc_len < 0) {
handle_float(value_buf, value_limit, num, DEFAULT_DECIMAL_PRECISION, 1);
} else {
Expand All @@ -363,9 +363,9 @@ char *append_vformat(char *dest, char *limit, const char *format,
} else if (ch == 'o') {
long num;
if (long_arg) {
num = va_arg(args, long);
num = va_arg(*args, long);
} else {
num = va_arg(args, int);
num = va_arg(*args, int);
}
handle_decimal(value_buf, value_limit, num, 8);
value = value_buf;
Expand All @@ -374,21 +374,21 @@ char *append_vformat(char *dest, char *limit, const char *format,
prefix_len = 1;
}
} else if (ch == 'p') {
DMALLOC_PNT pnt = va_arg(args, DMALLOC_PNT);
DMALLOC_PNT pnt = va_arg(*args, DMALLOC_PNT);
PNT_ARITH_TYPE num = (PNT_ARITH_TYPE)pnt;
handle_pointer(value_buf, value_limit, num, 16);
value = value_buf;
// because %#p throws a gcc warning, I've decreed that %p has a 0x hex prefix
prefix = "0x";
prefix_len = 2;
} else if (ch == 's') {
value = va_arg(args, char *);
value = va_arg(*args, char *);
} else if (ch == 'u') {
unsigned long num;
if (long_arg) {
num = va_arg(args, unsigned long);
num = va_arg(*args, unsigned long);
} else {
num = va_arg(args, unsigned int);
num = va_arg(*args, unsigned int);
}
char *value_buf_p = value_buf;
value_buf_p = append_ulong(value_buf_p, value_limit, num, 10);
Expand All @@ -397,9 +397,9 @@ char *append_vformat(char *dest, char *limit, const char *format,
} else if (ch == 'x') {
long num;
if (long_arg) {
num = va_arg(args, long);
num = va_arg(*args, long);
} else {
num = va_arg(args, int);
num = va_arg(*args, int);
}
handle_decimal(value_buf, value_limit, num, 16);
if (format_prefix) {
Expand Down Expand Up @@ -469,7 +469,7 @@ char *append_format(char *dest, char *limit, const char *format, ...)
char *dest_p;

va_start(args, format);
dest_p = append_vformat(dest, limit, format, args);
dest_p = append_vformat(dest, limit, format, &args);
va_end(args);

return dest_p;
Expand All @@ -496,7 +496,7 @@ char *append_null(char *dest, char *limit)
* causing the library to go recursive.
*/
int loc_vsnprintf(char *buf, const int size, const char *format,
va_list args)
va_list *args)
{
char *limit, *buf_p;
limit = buf + size;
Expand All @@ -516,7 +516,7 @@ int loc_snprintf(char *buf, const int size, const char *format, ...)
int len;

va_start(args, format);
len = loc_vsnprintf(buf, size, format, args);
len = loc_vsnprintf(buf, size, format, &args);
va_end(args);

return len;
Expand All @@ -529,7 +529,7 @@ void loc_printf(const char *format, ...)
{
va_list args;
va_start(args, format);
loc_vfprintf(stdout, format, args);
loc_vfprintf(stdout, format, &args);
va_end(args);
}

Expand All @@ -540,14 +540,14 @@ void loc_fprintf(FILE *file, const char *format, ...)
{
va_list args;
va_start(args, format);
loc_vfprintf(file, format, args);
loc_vfprintf(file, format, &args);
va_end(args);
}

/*
* Local implementation of vfprintf so we can use %p and other non-standard formats.
*/
void loc_vfprintf(FILE *file, const char *format, va_list args)
void loc_vfprintf(FILE *file, const char *format, va_list *args)
{
// these are simple messages so this limit is ok
char buf[256];
Expand All @@ -565,14 +565,14 @@ void loc_dprintf(int fd, const char *format, ...)
{
va_list args;
va_start(args, format);
loc_vdprintf(fd, format, args);
loc_vdprintf(fd, format, &args);
va_end(args);
}

/*
* Local implementation of vdprintf so we can use %p and other non-standard formats.
*/
void loc_vdprintf(int fd, const char *format, va_list args)
void loc_vdprintf(int fd, const char *format, va_list *args)
{
// these are simple messages so this limit is ok
char buf[256];
Expand Down
8 changes: 4 additions & 4 deletions append.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ char *append_pointer(char *dest, char *limit, PNT_ARITH_TYPE value, int base);
*/
extern
char *append_vformat(char *dest, char *limit, const char *format,
va_list args);
va_list *args);

/*
* Append a varargs format to destination. Pointer to the end of the
Expand All @@ -98,7 +98,7 @@ char *append_null(char *dest, char *limit);
*/
extern
int loc_vsnprintf(char *buf, const int size, const char *format,
va_list args);
va_list *args);

/*
* Local implementation of snprintf. We are doing this trying to not
Expand All @@ -124,7 +124,7 @@ void loc_fprintf(FILE *file, const char *format, ...);
* Local implementation of vfprintf so we can use %p and other non-standard formats.
*/
extern
void loc_vfprintf(FILE *file, const char *format, va_list args);
void loc_vfprintf(FILE *file, const char *format, va_list *args);

/*
* Local implementation of dprintf so we can use %p and other non-standard formats.
Expand All @@ -136,7 +136,7 @@ void loc_dprintf(int fd, const char *format, ...);
* Local implementation of vdprintf so we can use %p and other non-standard formats.
*/
extern
void loc_vdprintf(int fd, const char *format, va_list args);
void loc_vdprintf(int fd, const char *format, va_list *args);

/*<<<<<<<<<< This is end of the auto-generated output from fillproto. */

Expand Down
2 changes: 1 addition & 1 deletion error.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ char *_dmalloc_ptime(const TIME_TYPE *time_p, char *buf, const int buf_size,
*
* args -> Already converted pointer to a stdarg list.
*/
void _dmalloc_vmessage(const char *format, va_list args)
void _dmalloc_vmessage(const char *format, va_list *args)
{
char *str_p, *bounds_p;
int len;
Expand Down
2 changes: 1 addition & 1 deletion error.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ char *_dmalloc_ptime(const TIME_TYPE *time_p, char *buf, const int buf_size,
* args -> Already converted pointer to a stdarg list.
*/
extern
void _dmalloc_vmessage(const char *format, va_list args);
void _dmalloc_vmessage(const char *format, va_list *args);

/*
* void _dmalloc_die
Expand Down
4 changes: 2 additions & 2 deletions user_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,7 @@ void dmalloc_log_changed(const unsigned long mark, const int not_freed_b,
*
* args -> Already converted pointer to a stdarg list.
*/
void dmalloc_vmessage(const char *format, va_list args)
void dmalloc_vmessage(const char *format, va_list *args)
{
_dmalloc_vmessage(format, args);
}
Expand All @@ -1847,7 +1847,7 @@ void dmalloc_message(const char *format, ...)
va_list args;

va_start(args, format);
_dmalloc_vmessage(format, args);
_dmalloc_vmessage(format, &args);
va_end(args);
}

Expand Down
2 changes: 1 addition & 1 deletion user_malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ void dmalloc_log_changed(const unsigned long mark, const int not_freed_b,
* args -> Already converted pointer to a stdarg list.
*/
extern
void dmalloc_vmessage(const char *format, va_list args);
void dmalloc_vmessage(const char *format, va_list *args);

/*
* void dmalloc_message
Expand Down