library: standardize extents_free_all() logic, 3rd gen

As those 3rd generation newlib APIs evolved so too did
the extents_free_all() function. Most versions of this
function required the callers to first verify that the
extents anchor wasn't empty, which was poor etiquette.

This simple function should have been much more robust
and forgiving. With this commit, it fnally becomes so.

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-07-01 00:00:00 -05:00 committed by Craig Small
parent 458845f575
commit eff9fbc06e
5 changed files with 12 additions and 15 deletions

View File

@ -401,11 +401,11 @@ static inline void cleanup_stacks_all (
static void extents_free_all (
struct procps_meminfo *info)
{
do {
while (info->extents) {
struct stacks_extent *p = info->extents;
info->extents = info->extents->next;
free(p);
} while (info->extents);
};
} // end: extents_free_all

View File

@ -832,14 +832,11 @@ static struct stacks_extent *extent_cut (
static void extents_free_all (
struct procps_pidsinfo *info)
{
struct stacks_extent *ext = info->extents;
while (ext) {
info->extents = ext->next;
free(ext);
ext = info->extents;
while (info->extents) {
struct stacks_extent *p = info->extents;
info->extents = info->extents->next;
free(p);
};
info->dirty_stacks = 0;
} // end: extents_free_all

View File

@ -549,11 +549,11 @@ static inline void cleanup_stacks_all (
static void extents_free_all (
struct ext_support *this)
{
do {
while (this->extents) {
struct stacks_extent *p = this->extents;
this->extents = this->extents->next;
free(p);
} while (this->extents);
};
} // end: extents_free_all

View File

@ -319,11 +319,11 @@ static inline void cleanup_stacks_all (
static void extents_free_all (
struct ext_support *this)
{
do {
while (this->extents) {
struct stacks_extent *p = this->extents;
this->extents = this->extents->next;
free(p);
} while (this->extents);
};
} // end: extents_free_all

View File

@ -766,11 +766,11 @@ static inline void cleanup_stacks_all (
static void extents_free_all (
struct procps_vmstat *info)
{
do {
while (info->extents) {
struct stacks_extent *p = info->extents;
info->extents = info->extents->next;
free(p);
} while (info->extents);
};
} // end: extents_free_all