projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix uninit variable (hits_limit)
[idzebra-moved-to-github.git]
/
dict
/
dcompact.c
diff --git
a/dict/dcompact.c
b/dict/dcompact.c
index
715b0a2
..
1c792b3
100644
(file)
--- a/
dict/dcompact.c
+++ b/
dict/dcompact.c
@@
-1,8
+1,5
@@
-/* $Id: dcompact.c,v 1.10 2004-11-19 10:26:54 heikki Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
- Index Data Aps
-
-This file is part of the Zebra server.
+/* This file is part of the Zebra server.
+ Copyright (C) 1994-2011 Index Data
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
@@
-15,20
+12,22
@@
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
*/
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
-#include <yaz/ylog.h>
-#include <dict.h>
+#include "dict-p.h"
static void dict_copy_page(Dict dict, char *to_p, char *from_p, int *map)
{
static void dict_copy_page(Dict dict, char *to_p, char *from_p, int *map)
{
@@
-39,7
+38,7
@@
static void dict_copy_page(Dict dict, char *to_p, char *from_p, int *map)
from_indxp = (short*) ((char*) from_p+DICT_bsize(from_p));
to_indxp = (short*) ((char*) to_p+DICT_bsize(to_p));
to_info = (char*) to_p + DICT_infoffset;
from_indxp = (short*) ((char*) from_p+DICT_bsize(from_p));
to_indxp = (short*) ((char*) to_p+DICT_bsize(to_p));
to_info = (char*) to_p + DICT_infoffset;
- for (i = DICT_nodir (from_p); --i >= 0; )
+ for (i = DICT_nodir(from_p); --i >= 0; )
{
if (*--from_indxp > 0) /* tail string here! */
{
{
if (*--from_indxp > 0) /* tail string here! */
{
@@
-50,7
+49,7
@@
static void dict_copy_page(Dict dict, char *to_p, char *from_p, int *map)
from_info = (char*) from_p + *from_indxp;
*--to_indxp = to_info - to_p;
slen = (dict_strlen((Dict_char*) from_info)+1)*sizeof(Dict_char);
from_info = (char*) from_p + *from_indxp;
*--to_indxp = to_info - to_p;
slen = (dict_strlen((Dict_char*) from_info)+1)*sizeof(Dict_char);
- memcpy (to_info, from_info, slen);
+ memcpy(to_info, from_info, slen);
from_info += slen;
to_info += slen;
}
from_info += slen;
to_info += slen;
}
@@
-66,20
+65,20
@@
static void dict_copy_page(Dict dict, char *to_p, char *from_p, int *map)
*--to_indxp = -(to_info - to_p);
from_info = (char*) from_p - *from_indxp;
*--to_indxp = -(to_info - to_p);
from_info = (char*) from_p - *from_indxp;
- memcpy (&subptr, from_info, sizeof(subptr));
+ memcpy(&subptr, from_info, sizeof(subptr));
subptr = map[subptr];
from_info += sizeof(Dict_ptr);
subptr = map[subptr];
from_info += sizeof(Dict_ptr);
- memcpy (&subchar, from_info, sizeof(subchar));
+ memcpy(&subchar, from_info, sizeof(subchar));
from_info += sizeof(Dict_char);
from_info += sizeof(Dict_char);
- memcpy (to_info, &subptr, sizeof(Dict_ptr));
+ memcpy(to_info, &subptr, sizeof(Dict_ptr));
to_info += sizeof(Dict_ptr);
to_info += sizeof(Dict_ptr);
- memcpy (to_info, &subchar, sizeof(Dict_char));
+ memcpy(to_info, &subchar, sizeof(Dict_char));
to_info += sizeof(Dict_char);
}
to_info += sizeof(Dict_char);
}
- assert (to_info < (char*) to_indxp);
+ assert(to_info < (char*) to_indxp);
slen = *from_info+1;
slen = *from_info+1;
- memcpy (to_info, from_info, slen);
+ memcpy(to_info, from_info, slen);
to_info += slen;
++no;
}
to_info += slen;
++no;
}
@@
-88,18
+87,18
@@
static void dict_copy_page(Dict dict, char *to_p, char *from_p, int *map)
DICT_nodir(to_p) = no;
}
DICT_nodir(to_p) = no;
}
-int dict_copy_compact (BFiles bfs, const char *from_name, const char *to_name)
+int dict_copy_compact(BFiles bfs, const char *from_name, const char *to_name)
{
int no_dir = 0;
Dict dict_from, dict_to;
int *map, i;
{
int no_dir = 0;
Dict dict_from, dict_to;
int *map, i;
- dict_from = dict_open (bfs, from_name, 0, 0, 0, 4096);
+ dict_from = dict_open(bfs, from_name, 0, 0, 0, 4096);
if (!dict_from)
return -1;
if (!dict_from)
return -1;
- map = (int *) xmalloc ((dict_from->head.last+1) * sizeof(*map));
- for (i = 0; i <= (int) (dict_from->head.last); i++)
+ map = (int *) xmalloc((dict_from->head.last+1) * sizeof(*map));
+ for (i = 0; i <= (int)(dict_from->head.last); i++)
map[i] = -1;
map[i] = -1;
- dict_to = dict_open (bfs, to_name, 0, 1, 1, 4096);
+ dict_to = dict_open(bfs, to_name, 0, 1, 1, 4096);
if (!dict_to)
return -1;
map[0] = 0;
if (!dict_to)
return -1;
map[0] = 0;
@@
-110,28
+109,28
@@
int dict_copy_compact (BFiles bfs, const char *from_name, const char *to_name)
void *buf;
int size;
#if 0
void *buf;
int size;
#if 0
- yaz_log (YLOG_LOG, "map[%d] = %d", i, map[i]);
+ yaz_log(YLOG_LOG, "map[%d] = %d", i, map[i]);
#endif
#endif
- dict_bf_readp (dict_from->dbf, i, &buf);
+ dict_bf_readp(dict_from->dbf, i, &buf);
size = ((DICT_size(buf)+sizeof(short)-1)/sizeof(short) +
DICT_nodir(buf))*sizeof(short);
map[i+1] = map[i] + size;
no_dir += DICT_nodir(buf);
}
#if 0
size = ((DICT_size(buf)+sizeof(short)-1)/sizeof(short) +
DICT_nodir(buf))*sizeof(short);
map[i+1] = map[i] + size;
no_dir += DICT_nodir(buf);
}
#if 0
- yaz_log (YLOG_LOG, "map[%d] = %d", i, map[i]);
- yaz_log (YLOG_LOG, "nodir = %d", no_dir);
+ yaz_log(YLOG_LOG, "map[%d] = %d", i, map[i]);
+ yaz_log(YLOG_LOG, "nodir = %d", no_dir);
#endif
dict_to->head.root = map[1];
dict_to->head.last = map[i];
for (i = 1; i< (int) (dict_from->head.last); i++)
{
void *old_p, *new_p;
#endif
dict_to->head.root = map[1];
dict_to->head.last = map[i];
for (i = 1; i< (int) (dict_from->head.last); i++)
{
void *old_p, *new_p;
- dict_bf_readp (dict_from->dbf, i, &old_p);
+ dict_bf_readp(dict_from->dbf, i, &old_p);
- yaz_log (YLOG_LOG, "dict_bf_newp no=%d size=%d", map[i],
+ yaz_log(YLOG_LOG, "dict_bf_newp no=%d size=%d", map[i],
map[i+1] - map[i]);
map[i+1] - map[i]);
- dict_bf_newp (dict_to->dbf, map[i], &new_p, map[i+1] - map[i]);
+ dict_bf_newp(dict_to->dbf, map[i], &new_p, map[i+1] - map[i]);
DICT_type(new_p) = 0;
DICT_backptr(new_p) = map[i-1];
DICT_type(new_p) = 0;
DICT_backptr(new_p) = map[i-1];
@@
-139,7
+138,16
@@
int dict_copy_compact (BFiles bfs, const char *from_name, const char *to_name)
dict_copy_page(dict_from, (char*) new_p, (char*) old_p, map);
}
dict_copy_page(dict_from, (char*) new_p, (char*) old_p, map);
}
- dict_close (dict_from);
- dict_close (dict_to);
+ dict_close(dict_from);
+ dict_close(dict_to);
return 0;
}
return 0;
}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+