aboutsummaryrefslogtreecommitdiff
path: root/dict.c
diff options
context:
space:
mode:
authorJuan Cespedes <cespedes@debian.org>2003-02-01 19:02:37 +0100
committerJuan Cespedes <cespedes@debian.org>2003-02-01 19:02:37 +0100
commita0ccf39a68c0fcdf2165bde0f9b70ed12fc61cd8 (patch)
treeafe23bec662ac61ab1a8c1bdb6463c3c017f775b /dict.c
parent7186e2af704f4458e6383e8a92482594db29b597 (diff)
downloadltrace-a0ccf39a68c0fcdf2165bde0f9b70ed12fc61cd8.tar.gz
Version 0.3.29
* Align return values depending on screen width * Updated list of syscalls and signals to Linux 2.4.20 * Fixed bug introduced in 0.3.27 which caused -L option to segfault
Diffstat (limited to 'dict.c')
-rw-r--r--dict.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/dict.c b/dict.c
index ae7d220..d4676f3 100644
--- a/dict.c
+++ b/dict.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "debug.h"
@@ -52,6 +53,7 @@ dict_clear(struct dict * d) {
int i;
struct dict_entry * entry, * nextentry;
+ assert(d);
for (i = 0; i < DICTTABLESIZE; i++) {
for (entry = d->buckets[i]; entry != NULL; entry = nextentry) {
nextentry = entry->next;
@@ -68,6 +70,7 @@ dict_enter(struct dict * d, void * key, void * value) {
unsigned int hash = d->key2hash(key);
unsigned int bucketpos = hash % DICTTABLESIZE;
+ assert(d);
newentry = malloc(sizeof(struct dict_entry));
if (!newentry) {
perror("malloc");
@@ -95,6 +98,7 @@ dict_find_entry(struct dict * d, void * key) {
unsigned int bucketpos = hash % DICTTABLESIZE;
struct dict_entry * entry;
+ assert(d);
for (entry = d->buckets[bucketpos]; entry; entry = entry->next) {
if (hash != entry->hash) {
continue;
@@ -110,6 +114,7 @@ void
dict_apply_to_all(struct dict * d, void (*func)(void *key, void *value, void *data), void *data) {
int i;
+ assert(d);
for (i = 0; i < DICTTABLESIZE; i++) {
struct dict_entry * entry = d->buckets[i];
while (entry) {
@@ -126,6 +131,7 @@ dict_key2hash_string(void * key) {
const char * s = (const char *)key;
unsigned int total = 0, shift = 0;
+ assert(key);
while (*s) {
total = total ^ ((*s) << shift);
shift += 5;
@@ -137,6 +143,8 @@ dict_key2hash_string(void * key) {
int
dict_key_cmp_string(void * key1, void * key2) {
+ assert(key1);
+ assert(key2);
return strcmp((const char *)key1, (const char *)key2);
}