e7ed6d24fc4fd23f8048ff4e15e022253f6c496e
[idzebra-moved-to-github.git] / dict / close.c
1 /* This file is part of the Zebra server.
2    Copyright (C) 1995-2008 Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19
20
21
22 #include <stdlib.h>
23 #include <string.h>
24 #include <stdio.h>
25 #include <assert.h>
26
27 #include "dict-p.h"
28
29 int dict_close (Dict dict)
30 {
31     if (!dict)
32         return 0;
33
34     if (dict->rw)
35     {
36         void *head_buf;
37         dict_bf_readp (dict->dbf, 0, &head_buf);
38         memcpy (head_buf, &dict->head, sizeof(dict->head));
39         dict_bf_touch (dict->dbf, 0);        
40     }
41     dict_bf_close (dict->dbf);
42     xfree (dict);
43     return 0;
44 }
45
46 /*
47  * Local variables:
48  * c-basic-offset: 4
49  * indent-tabs-mode: nil
50  * End:
51  * vim: shiftwidth=4 tabstop=8 expandtab
52  */
53