/[zanavi_public1]/navit/navit/maptool/itembin_buffer.c
ZANavi

Contents of /navit/navit/maptool/itembin_buffer.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Mon Feb 4 17:41:59 2013 UTC (7 years, 6 months ago) by zoff99
File MIME type: text/plain
File size: 2825 byte(s)
new map version, lots of fixes and experimental new features
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2012 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License 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
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * Navit, a modular navigation system.
22 * Copyright (C) 2005-2011 Navit Team
23 *
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * version 2 as published by the Free Software Foundation.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the
35 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 * Boston, MA 02110-1301, USA.
37 */
38 #include <string.h>
39 #include <stdlib.h>
40 #include "maptool.h"
41 #include "debug.h"
42
43 // static char buffer[800000]; --> not thread safe!!
44 // struct item_bin *item_bin = (struct item_bin *) (void *) ib_buffer_; --> not thread safe
45
46 struct node_item *
47 read_node_item(FILE *in, int local_thread_num)
48 {
49 struct node_item *node_item = (struct node_item *) (void *) ib_buffer_array[local_thread_num];
50 if (fread(node_item, sizeof(struct node_item), 1, in) != 1)
51 return NULL;
52 return node_item;
53 }
54
55 struct item_bin *
56 read_item(FILE *in, int local_thread_num)
57 {
58 struct item_bin *ib = (struct item_bin *) ib_buffer_array[local_thread_num];
59 for (;;)
60 {
61 switch (item_bin_read(ib, in))
62 {
63 case 0:
64 return NULL;
65 case 2:
66 dbg_assert((ib->len + 1) * 4 < sizeof(ib_buffer_array[local_thread_num]));
67 bytes_read += (ib->len + 1) * sizeof(int);
68 return ib;
69 default:
70 continue;
71 }
72 }
73 }
74
75 struct item_bin *
76 read_item_range(FILE *in, int *min, int *max, int local_thread_num)
77 {
78 struct range r;
79
80 if (fread(&r, sizeof(r), 1, in) != 1)
81 return NULL;
82 *min = r.min;
83 *max = r.max;
84 return read_item(in, local_thread_num);
85 }
86
87 struct item_bin *
88 init_item(enum item_type type, int local_thread_num)
89 {
90 struct item_bin *ib = (struct item_bin *) ib_buffer_array[local_thread_num];
91
92 item_bin_init(ib, type);
93 return ib;
94 }

   
Visit the ZANavi Wiki