Skip to content

Commit

Permalink
Merge pull request #310 from boostorg/feature/va-start
Browse files Browse the repository at this point in the history
Restore removed va_start calls; add missing va_end as reported in #264.
  • Loading branch information
robertramey committed Mar 23, 2024
2 parents 2805bc3 + d52537a commit 2e044c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
15 changes: 9 additions & 6 deletions include/boost/serialization/extended_type_info_no_rtti.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,26 @@ class extended_type_info_no_rtti :
}
void * construct(unsigned int count, ...) const BOOST_OVERRIDE {
// count up the arguments
void * r = NULL;
std::va_list ap;
va_start(ap, count);
switch(count){
case 0:
return factory<typename boost::remove_const< T >::type, 0>(ap);
r = factory<typename boost::remove_const< T >::type, 0>(ap);
case 1:
return factory<typename boost::remove_const< T >::type, 1>(ap);
r = factory<typename boost::remove_const< T >::type, 1>(ap);
case 2:
return factory<typename boost::remove_const< T >::type, 2>(ap);
r = factory<typename boost::remove_const< T >::type, 2>(ap);
case 3:
return factory<typename boost::remove_const< T >::type, 3>(ap);
r = factory<typename boost::remove_const< T >::type, 3>(ap);
case 4:
return factory<typename boost::remove_const< T >::type, 4>(ap);
r = factory<typename boost::remove_const< T >::type, 4>(ap);
default:
BOOST_ASSERT(false); // too many arguments
// throw exception here?
return NULL;
}
va_end(ap);
return r;
}
void destroy(void const * const p) const BOOST_OVERRIDE {
boost::serialization::access::destroy(
Expand Down
15 changes: 9 additions & 6 deletions include/boost/serialization/extended_type_info_typeid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,26 @@ class extended_type_info_typeid :
}
void * construct(unsigned int count, ...) const BOOST_OVERRIDE {
// count up the arguments
void * r = NULL;
std::va_list ap;
va_start(ap, count);
switch(count){
case 0:
return factory<typename boost::remove_const< T >::type, 0>(ap);
r = factory<typename boost::remove_const< T >::type, 0>(ap);
case 1:
return factory<typename boost::remove_const< T >::type, 1>(ap);
r = factory<typename boost::remove_const< T >::type, 1>(ap);
case 2:
return factory<typename boost::remove_const< T >::type, 2>(ap);
r = factory<typename boost::remove_const< T >::type, 2>(ap);
case 3:
return factory<typename boost::remove_const< T >::type, 3>(ap);
r = factory<typename boost::remove_const< T >::type, 3>(ap);
case 4:
return factory<typename boost::remove_const< T >::type, 4>(ap);
r = factory<typename boost::remove_const< T >::type, 4>(ap);
default:
BOOST_ASSERT(false); // too many arguments
// throw exception here?
return NULL;
}
va_end(ap);
return r;
}
void destroy(void const * const p) const BOOST_OVERRIDE {
boost::serialization::access::destroy(
Expand Down

0 comments on commit 2e044c7

Please sign in to comment.