Blame elf/stringtable_free.c

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