1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
/* ########################################################################
proc_dict.c
File: proc_dict.c
Path: /home/fournigault/c/X11/xcoral-2.31/proc_dict.c
Description:
Created: Fri Jan 27 11:25:07 MET 1995
Author: Dominique Leveque
Modified: Fri Jan 27 11:25:08 MET 1995
Last maintained by: Dominique Leveque
RCS $Revision$ $State$
########################################################################
Note:
########################################################################
Copyright (c) : Dominique Leveque
This program 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 Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or 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
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
######################################################################## */
#include "result_types.h"
#include "file_dict.h"
#include "proc_dict.h"
#include "browser_util.h"
#include <string.h>
#include <stdio.h>
/*------------------------------------------------------------------------------
// Le dictionnaire des procedures
//------------------------------------------------------------------------------
*/
ProcRec* proc_dict[PROC_DICT_SIZE];
int proc_count = 0;
/*------------------------------------------------------------------------------
*/
ProcRec* create_proc(proc_name, staticp, parsed_file)
char* proc_name;
int staticp;
char * parsed_file;
{
ProcRec** head;
ProcRec* current_proc;
int x_size;
get_head_Rec(proc_name, proc_dict, PROC_DICT_SIZE, head);
iter_Rec(proc_name, ProcRec, head, current_proc) {
if (current_proc->_impl_file &&
((! strcmp(parsed_file, current_proc->_impl_file->_name)) ||
((! staticp) && (! (current_proc->_decl & STATIC_PROC)))))
return current_proc;
}
if (current_proc == Null) {
x_size = sizeof(ProcRec) + PROC_PLENGTH + strlen(proc_name) + 1;
current_proc = (ProcRec*) xmalloc(x_size);
if (current_proc != Null) {
create_Rec(proc_name, ProcRec, head, current_proc, PROC_PREFIX, PROC_PLENGTH);
current_proc->_impl_file = Null;
current_proc->_impl_line = 0;
current_proc->_decl = 0;
current_proc->_hide = 0;
proc_count++;
}
}
return(current_proc);
}
/*------------------------------------------------------------------------------
*/
ProcRec* find_proc(proc_name)
char* proc_name;
{
ProcRec** head;
ProcRec* current_proc;
get_head_Rec(proc_name, proc_dict, PROC_DICT_SIZE, head);
assoc_Rec(proc_name, ProcRec, head, current_proc);
return(current_proc);
}
/*------------------------------------------------------------------------------
*/
typedef long Bits;
#define LAST_BIT ((sizeof(Bits) * 8) - 1)
static Bits erazed_bits[(PROC_DICT_SIZE + LAST_BIT) / (LAST_BIT + 1)];
void proc_eraze_file(file_name)
char* file_name;
{
Bits* erazed_slice;
FileRec* current_file;
ProcRec* current_proc;
int index;
current_file = find_file(file_name);
if (current_file != Null) {
erazed_slice = erazed_bits;
for (index = 0; index < PROC_DICT_SIZE; index++) {
current_proc = proc_dict[index];
while (current_proc != Null) {
if (current_proc->_impl_file == current_file) {
current_proc->_impl_file = Null;
current_proc->_impl_line = 0;
(*erazed_slice) |= ((0x00000001L) << (index & LAST_BIT));
}
current_proc = current_proc->_next;
}
if ((index & LAST_BIT) == LAST_BIT)
erazed_slice++;
}
}
}
/*------------------------------------------------------------------------------
*/
void garbage_proc()
{
Bits* erazed_slice;
ProcRec* previous_proc;
ProcRec* current_proc;
ProcRec* next_proc;
int index;
erazed_slice = erazed_bits;
for (index = 0; index < PROC_DICT_SIZE; index++) {
if ((*erazed_slice) == 0) {
index += LAST_BIT;
erazed_slice++;
}
else {
if (((*erazed_slice) & ((0x00000001L) << (index & LAST_BIT))) != 0) {
previous_proc = Null;
current_proc = proc_dict[index];
while (current_proc != Null) {
if (current_proc->_impl_file == Null) {
next_proc = current_proc->_next;
if (previous_proc == Null)
proc_dict[index] = next_proc;
else
previous_proc->_next = next_proc;
--proc_count;
free(current_proc);
current_proc = next_proc;
}
else {
previous_proc = current_proc;
current_proc = current_proc->_next;
}
}
}
if ((index & LAST_BIT) == LAST_BIT) {
*erazed_slice = 0;
erazed_slice++;
}
}
}
}
/*------------------------------------------------------------------------------
*/
void init_proc() {
Bits* erazed_slice;
int index;
erazed_slice = erazed_bits;
for (index = 0; index < PROC_DICT_SIZE; index++) {
if ((index & LAST_BIT) == LAST_BIT) {
*erazed_slice = 0;
erazed_slice++;
}
proc_dict[index] = Null;
}
}
|