diff options
author | Fred Fish <fnf@specifix.com> | 1996-03-24 00:22:50 +0000 |
---|---|---|
committer | Fred Fish <fnf@specifix.com> | 1996-03-24 00:22:50 +0000 |
commit | 4cfb23a94c8cd4aac096c54ee7f8fe28cdc5f525 (patch) | |
tree | 3221fbbd6af66a2ba9fba00d639f686928d07278 /gdb/bcache.c | |
parent | a319972ce65345235a584dc629ca3ae29b25fa44 (diff) | |
download | gdb-4cfb23a94c8cd4aac096c54ee7f8fe28cdc5f525.zip gdb-4cfb23a94c8cd4aac096c54ee7f8fe28cdc5f525.tar.gz gdb-4cfb23a94c8cd4aac096c54ee7f8fe28cdc5f525.tar.bz2 |
* os9kread.c (os9k_process_one_symbol): Note nonportable
assumption that an int can hold a char *.
* bcache.h (struct hashlink): Wrap data[] inside union with
double to force longest alignment.
(BCACHE_DATA): New macro to access data[].
(BCACHE_ALIGNMENT): New macro to get offset to data[].
* bcache.c (lookup_cache, bcache): Use BCACHE_DATA to get
address of cached data. Use BCACHE_ALIGNMENT to compute
amount of space to allocate for each hashlink struct.
Diffstat (limited to 'gdb/bcache.c')
-rw-r--r-- | gdb/bcache.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gdb/bcache.c b/gdb/bcache.c index af80afb..c47893b 100644 --- a/gdb/bcache.c +++ b/gdb/bcache.c @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "defs.h" #include "obstack.h" #include "bcache.h" +#include "gdb_string.h" /* For memcpy declaration */ /* FIXME: Incredibly simplistic hash generator. Probably way too expensive (consider long strings) and unlikely to have good distribution across hash @@ -67,9 +68,9 @@ lookup_cache (bytes, count, hashval, bcachep) linkp = hashtablep[hashval]; while (linkp != NULL) { - if (memcmp (linkp -> data, bytes, count) == 0) + if (memcmp (BCACHE_DATA (linkp), bytes, count) == 0) { - location = linkp -> data; + location = BCACHE_DATA (linkp); break; } linkp = linkp -> next; @@ -115,17 +116,17 @@ bcache (bytes, count, bcachep) { *hashtablepp = (struct hashlink **) obstack_alloc (&bcachep->cache, BCACHE_HASHSIZE * sizeof (struct hashlink *)); - bcachep -> cache_bytes += sizeof (struct hashlink *); + bcachep -> cache_bytes += BCACHE_HASHSIZE * sizeof (struct hashlink *); memset (*hashtablepp, 0, BCACHE_HASHSIZE * sizeof (struct hashlink *)); } linkpp = &(*hashtablepp)[hashval]; newlink = (struct hashlink *) - obstack_alloc (&bcachep->cache, sizeof (struct hashlink *) + count); - bcachep -> cache_bytes += sizeof (struct hashlink *) + count; - memcpy (newlink -> data, bytes, count); + obstack_alloc (&bcachep->cache, BCACHE_DATA_ALIGNMENT + count); + bcachep -> cache_bytes += BCACHE_DATA_ALIGNMENT + count; + memcpy (BCACHE_DATA (newlink), bytes, count); newlink -> next = *linkpp; *linkpp = newlink; - location = newlink -> data; + location = BCACHE_DATA (newlink); } } return (location); |