Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/*** map-table.c --- Mapping table ADT.
32
 *
33
 ** Author: Steve Folkes <smf@hermes.mod.uk>
34
 *
35
 *** Commentary:
36
 *
37
 * This file implements the mapping table routines used by the TDF linker.
38
 *
39
 *** Change Log:
40
 * $Log: map-table.c,v $
41
 * Revision 1.1.1.1  1998/01/17  15:57:19  release
42
 * First version to be checked into rolling release.
43
 *
44
 * Revision 1.3  1995/09/22  08:39:23  smf
45
 * Fixed problems with incomplete structures (to shut "tcc" up).
46
 * Fixed some problems in "name-key.c" (no real problems, but rewritten to
47
 * reduce the warnings that were output by "tcc" and "gcc").
48
 * Fixed bug CR95_354.tld-common-id-problem (library capsules could be loaded
49
 * more than once).
50
 *
51
 * Revision 1.2  1994/12/12  11:46:31  smf
52
 * Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
53
 * OSSG C Coding Standards.
54
 *
55
 * Revision 1.1.1.1  1994/07/25  16:03:33  smf
56
 * Initial import of TDF linker 3.5 non shared files.
57
 *
58
**/
59
 
60
/****************************************************************************/
61
 
62
#include "map-table.h"
63
 
64
#include "solve-cycles.h"
65
 
66
/*--------------------------------------------------------------------------*/
67
 
68
MapTableP
69
map_table_create PROTO_Z ()
70
{
71
    MapTableP table = ALLOCATE (MapTableT);
72
    unsigned  i;
73
 
74
    for (i = 0; i < MAP_TABLE_SIZE; i ++) {
75
	table->contents [i] = NIL (MapEntryP);
76
    }
77
    return (table);
78
}
79
 
80
MapEntryP
81
map_table_add PROTO_N ((table, key, count))
82
	      PROTO_T (MapTableP table X
83
		       NStringP  key X
84
		       unsigned  count)
85
{
86
    unsigned  hash_value = (nstring_hash_value (key) % MAP_TABLE_SIZE);
87
    MapEntryP next       = (table->contents [hash_value]);
88
    MapEntryP entry      = map_entry_create (key, next, count);
89
 
90
    table->contents [hash_value] = entry;
91
    return (entry);
92
}
93
 
94
MapEntryP
95
map_table_get PROTO_N ((table, key))
96
	      PROTO_T (MapTableP table X
97
		       NStringP  key)
98
{
99
    unsigned  hash_value = (nstring_hash_value (key) % MAP_TABLE_SIZE);
100
    MapEntryP entry      = (table->contents [hash_value]);
101
 
102
    while (entry) {
103
	if (nstring_equal (key, map_entry_key (entry))) {
104
	    return (entry);
105
	}
106
	entry = map_entry_next (entry);
107
    }
108
    return (NIL (MapEntryP));
109
}
110
 
111
void
112
map_table_iter PROTO_N ((table, proc, closure))
113
	       PROTO_T (MapTableP table X
114
			void    (*proc) PROTO_S ((MapEntryP, GenericP)) X
115
			GenericP  closure)
116
{
117
    unsigned i;
118
 
119
    for (i = 0; i < MAP_TABLE_SIZE; i ++) {
120
	MapEntryP entry = (table->contents [i]);
121
 
122
	while (entry) {
123
	    (*proc) (entry, closure);
124
	    entry = map_entry_next (entry);
125
	}
126
    }
127
}
128
 
129
/*
130
 * Local variables(smf):
131
 * eval: (include::add-path-entry "../os-interface" "../library")
132
 * eval: (include::add-path-entry "../generated")
133
 * end:
134
**/