Skip to content

Commit 40c05f6

Browse files
committed
Export vsnprintf_va_copy() and vsnprintf_va_end()
1 parent 849eaba commit 40c05f6

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

build.rs

-7
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,6 @@ impl bindgen::callbacks::ParseCallbacks for CustomCallbacks {
113113
if original_item_name == "RS_EMPTY_ARRAY_SENTINEL" {
114114
return Some("UA_EMPTY_ARRAY_SENTINEL".to_owned());
115115
}
116-
// Rename wrapper function back to its original name. See `wrapper.c` for details.
117-
if original_item_name == "RS_vsnprintf" {
118-
return Some("vsnprintf".to_owned());
119-
}
120-
if original_item_name == "RS_va_end" {
121-
return Some("va_end".to_owned());
122-
}
123116
None
124117
}
125118
}

wrapper.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
// such as Microsoft Windows.
55
//
66
// Other than the standard `vsnprintf()`, this function does not consume the passed
7-
// `va_list` argument! The caller is responsible for calling `va_end()` on the
7+
// `va_list` argument! The caller is responsible for calling `vsnprintf_va_end()` on the
88
// `va_list` argument eventually.
99
#if defined(_MSC_VER) && _MSC_VER < 1900
10-
int RS_vsnprintf(
10+
int vsnprintf_va_copy(
1111
char *buffer,
1212
size_t count,
1313
const char *format,
@@ -31,7 +31,7 @@ int RS_vsnprintf(
3131
return result;
3232
}
3333
#else
34-
int RS_vsnprintf(
34+
int vsnprintf_va_copy(
3535
char *buffer,
3636
size_t count,
3737
const char *format,
@@ -47,7 +47,7 @@ int RS_vsnprintf(
4747
}
4848
#endif
4949

50-
void RS_va_end(va_list args)
50+
void vsnprintf_va_end(va_list args)
5151
{
5252
va_end(args);
5353
}

wrapper.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ extern const void *const RS_EMPTY_ARRAY_SENTINEL;
2222
// such as Microsoft Windows.
2323
//
2424
// Other than the standard `vsnprintf()`, this implementation copies the `va_list`
25-
// argument before passing it along to allow repeated calls.
26-
int RS_vsnprintf(
25+
// argument before passing it along to allow repeated calls. The caller is responsible
26+
// to invoke `vsnprintf_va_end()` on the `va_list` argument eventually.
27+
int vsnprintf_va_copy(
2728
char *buffer,
2829
size_t count,
2930
const char *format,
3031
va_list args);
3132

32-
void RS_va_end(va_list args);
33+
// Wrapper for `va_end()` that is supposed to be used with `vsnprintf_va_copy()`.
34+
void vsnprintf_va_end(va_list args);

0 commit comments

Comments
 (0)