Blame elf/stringtable_free.c

Packit Service 5a525e
/* String tables for ld.so.cache construction.  Deallocation (for tests only).
Packit Service 5a525e
   Copyright (C) 2020 Free Software Foundation, Inc.
Packit Service 5a525e
   This file is part of the GNU C Library.
Packit Service 5a525e
Packit Service 5a525e
   This program is free software; you can redistribute it and/or modify
Packit Service 5a525e
   it under the terms of the GNU General Public License as published
Packit Service 5a525e
   by the Free Software Foundation; version 2 of the License, or
Packit Service 5a525e
   (at your option) any later version.
Packit Service 5a525e
Packit Service 5a525e
   This program is distributed in the hope that it will be useful,
Packit Service 5a525e
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 5a525e
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 5a525e
   GNU General Public License for more details.
Packit Service 5a525e
Packit Service 5a525e
   You should have received a copy of the GNU General Public License
Packit Service 5a525e
   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit Service 5a525e
Packit Service 5a525e
#include <stdlib.h>
Packit Service 5a525e
#include <stringtable.h>
Packit Service 5a525e
Packit Service 5a525e
void
Packit Service 5a525e
stringtable_free (struct stringtable *table)
Packit Service 5a525e
{
Packit Service 5a525e
  for (uint32_t i = 0; i < table->allocated; ++i)
Packit Service 5a525e
    for (struct stringtable_entry *e = table->entries[i]; e != NULL; )
Packit Service 5a525e
      {
Packit Service 5a525e
        struct stringtable_entry *next = e->next;
Packit Service 5a525e
        free (e);
Packit Service 5a525e
        e = next;
Packit Service 5a525e
      }
Packit Service 5a525e
  free (table->entries);
Packit Service 5a525e
  *table = (struct stringtable) { 0, };
Packit Service 5a525e
}