Coverage Report

Created: 2025-07-11 06:11

/src/gdbm/src/gdbmreorg.c
Line
Count
Source
1
/* gdbmreorg.c - Reorganize the database file. */
2
3
/* This file is part of GDBM, the GNU data base manager.
4
   Copyright (C) 1990-2025 Free Software Foundation, Inc.
5
6
   GDBM is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3, or (at your option)
9
   any later version.
10
11
   GDBM is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
16
   You should have received a copy of the GNU General Public License
17
   along with GDBM. If not, see <http://www.gnu.org/licenses/>.   */
18
19
/* Include system configuration before all else. */
20
#include "autoconf.h"
21
#include "gdbmdefs.h"
22
23
/* Reorganize the database.  This requires creating a new file and inserting
24
   all the elements in the old file DBF into the new file.  The new file
25
   is then renamed to the same name as the old file and DBF is updated to
26
   contain all the correct information about the new file.  If an error
27
   is detected, the return value is negative.  The value zero is returned
28
   after a successful reorganization. */
29
30
int
31
gdbm_reorganize (GDBM_FILE dbf)
32
2.20k
{
33
2.20k
  gdbm_recovery rcvr;
34
  
35
  /* Return immediately if the database needs recovery */  
36
2.20k
  GDBM_ASSERT_CONSISTENCY (dbf, -1);
37
38
2.20k
  rcvr.max_failures = 0;
39
2.20k
  return gdbm_recover (dbf, &rcvr, GDBM_RCVR_MAX_FAILURES|GDBM_RCVR_FORCE);
40
2.20k
}