Mercurial > hg > forks > dxa
annotate table.c @ 2:ec2f8f6f1dc9
Cleanup pass #1: Get rid of some ancient K&R-isms.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 24 Feb 2015 20:28:57 +0200 |
parents | 4410c9c7750d |
children | a2a81589380d |
rev | line source |
---|---|
0 | 1 /*\ |
2 * dxa v0.1.1 -- symbolic 65xx disassembler | |
3 * | |
4 * Copyright (C) 1993, 1994 Marko M\"akel\"a | |
5 * | |
6 * This program 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 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program 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 this program; if not, write to the Free Software | |
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 * | |
20 * Contacting the author: | |
21 * | |
22 * Via Internet E-mail: | |
23 * <Marko.Makela@FTP.FUNET.FI> | |
24 * | |
25 * Via Snail Mail: | |
26 * Marko M\"akel\"a | |
27 * Sillitie 10 A | |
28 * FIN-01480 VANTAA | |
29 * Finland | |
30 \*/ | |
31 | |
32 /* table.c */ | |
33 #define _TABLE_C_ | |
34 | |
35 #include <stdlib.h> | |
36 #include "proto.h" | |
37 | |
38 static unsigned int firstunused = 0; | |
39 | |
2
ec2f8f6f1dc9
Cleanup pass #1: Get rid of some ancient K&R-isms.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
40 |
0 | 41 table *FindNextEntryType (table *entry, unsigned char andmask, |
42 unsigned char eormask) | |
43 { | |
44 if (!scantable) return NULL; | |
45 | |
46 if (!entry || entry >= &scantable[entrycount]) | |
47 entry = scantable; | |
48 else if (++entry >= &scantable[entrycount]) | |
49 return NULL; | |
50 | |
51 for (; entry < &scantable[entrycount]; entry++) | |
52 if (entry->type && !((entry->type & andmask) ^ eormask)) | |
53 return entry; | |
54 | |
55 return NULL; | |
56 } | |
57 | |
2
ec2f8f6f1dc9
Cleanup pass #1: Get rid of some ancient K&R-isms.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
58 |
0 | 59 table *FindNextEntryTypeParent (table *entry, ADDR_T parent, |
60 unsigned char andmask, unsigned char eormask) | |
61 { | |
62 if (!scantable) return NULL; | |
63 | |
64 | |
65 if (!entry || entry >= &scantable[entrycount]) | |
66 entry = scantable; | |
67 else if (++entry >= &scantable[entrycount]) | |
68 return NULL; | |
69 | |
70 for (; entry < &scantable[entrycount]; entry++) | |
71 if (entry->parent == parent && entry->type && | |
72 !((entry->type & andmask) ^ eormask)) | |
73 return entry; | |
74 | |
75 return NULL; | |
76 } | |
77 | |
2
ec2f8f6f1dc9
Cleanup pass #1: Get rid of some ancient K&R-isms.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
78 |
0 | 79 table *FindNextEntry (table *entry, ADDR_T address, |
80 unsigned char andmask, unsigned char eormask) | |
81 { | |
82 if (!scantable) return NULL; | |
83 | |
84 if (!entry || entry >= &scantable[entrycount]) | |
85 entry = scantable; | |
86 else if (++entry >= &scantable[entrycount]) | |
87 return NULL; | |
88 | |
89 for (; entry < &scantable[entrycount]; entry++) | |
90 if (entry->address == address && entry->type && | |
91 !((entry->type & andmask) ^ eormask)) | |
92 return entry; | |
93 | |
94 return NULL; | |
95 } | |
96 | |
2
ec2f8f6f1dc9
Cleanup pass #1: Get rid of some ancient K&R-isms.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
97 |
0 | 98 void AddEntry (ADDR_T address, ADDR_T parent, unsigned char type) |
99 { | |
100 if (firstunused < entrycount) { | |
101 scantable[firstunused].address = address; | |
102 scantable[firstunused].parent = parent; | |
103 scantable[firstunused].type = type; | |
104 | |
105 while (++firstunused < entrycount && scantable[firstunused].type); | |
106 } | |
107 else { | |
108 scantable = scantable ? | |
109 realloc (scantable, (entrycount + 1) * sizeof *scantable) : | |
110 malloc (sizeof *scantable); | |
111 | |
112 scantable[entrycount].address = address; | |
113 scantable[entrycount].parent = parent; | |
114 scantable[entrycount].type = type; | |
115 | |
116 firstunused = ++entrycount; | |
117 } | |
118 } | |
119 | |
2
ec2f8f6f1dc9
Cleanup pass #1: Get rid of some ancient K&R-isms.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
120 |
0 | 121 void DeleteEntry (table *entry) |
122 { | |
123 entry -> type = TBL_DELETED; | |
124 | |
125 if (firstunused > entry - scantable) | |
126 firstunused = entry - scantable; | |
127 } |