~ubuntu-branches/ubuntu/utopic/ltrace/utopic-proposed

« back to all changes in this revision

Viewing changes to dict.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-07-28 16:44:35 UTC
  • mfrom: (1.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090728164435-d88mottol5xryqk7
Tags: 0.5.3-2ubuntu1
* Merge from debian unstable, remaining changes: LP: #404856
  - Add lpia to architecture list.
  - Use libelf-dev instead of libelfg0-dev
  - Define _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE in debian/rules CFLAGS.
    The configure script has a bug where it can't properly cope with the need
    to define these before detecting the use of elfutils.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#include <string.h>
4
4
#include <assert.h>
5
5
 
6
 
#include "debug.h"
 
6
#include "common.h"
7
7
 
8
8
/*
9
9
  Dictionary based on code by Morten Eriksen <mortene@sim.no>.
10
10
*/
11
11
 
12
 
#include "dict.h"
13
 
 
14
12
struct dict_entry {
15
13
        unsigned int hash;
16
14
        void *key;
30
28
        int (*key_cmp) (void *, void *);
31
29
};
32
30
 
33
 
struct dict *
 
31
Dict *
34
32
dict_init(unsigned int (*key2hash) (void *),
35
33
                       int (*key_cmp) (void *, void *)) {
36
 
        struct dict *d;
 
34
        Dict *d;
37
35
        int i;
38
36
 
39
37
        debug(DEBUG_FUNCTION, "dict_init()");
40
38
 
41
 
        d = malloc(sizeof(struct dict));
 
39
        d = malloc(sizeof(Dict));
42
40
        if (!d) {
43
41
                perror("malloc()");
44
42
                exit(1);
52
50
}
53
51
 
54
52
void
55
 
dict_clear(struct dict *d) {
 
53
dict_clear(Dict *d) {
56
54
        int i;
57
55
        struct dict_entry *entry, *nextentry;
58
56
 
69
67
}
70
68
 
71
69
int
72
 
dict_enter(struct dict *d, void *key, void *value) {
 
70
dict_enter(Dict *d, void *key, void *value) {
73
71
        struct dict_entry *entry, *newentry;
74
72
        unsigned int hash;
75
73
        unsigned int bucketpos;
105
103
}
106
104
 
107
105
void *
108
 
dict_find_entry(struct dict *d, void *key) {
 
106
dict_find_entry(Dict *d, void *key) {
109
107
        unsigned int hash;
110
108
        unsigned int bucketpos;
111
109
        struct dict_entry *entry;
128
126
}
129
127
 
130
128
void
131
 
dict_apply_to_all(struct dict *d,
 
129
dict_apply_to_all(Dict *d,
132
130
                  void (*func) (void *key, void *value, void *data), void *data) {
133
131
        int i;
134
132
 
181
179
        return key1 - key2;
182
180
}
183
181
 
184
 
struct dict *
185
 
dict_clone(struct dict *old, void * (*key_clone)(void*), void * (*value_clone)(void*)) {
186
 
        struct dict *d;
 
182
Dict *
 
183
dict_clone(Dict *old, void * (*key_clone)(void*), void * (*value_clone)(void*)) {
 
184
        Dict *d;
187
185
        int i;
188
186
 
189
187
        debug(DEBUG_FUNCTION, "dict_clone()");
190
188
 
191
 
        d = malloc(sizeof(struct dict));
 
189
        d = malloc(sizeof(Dict));
192
190
        if (!d) {
193
191
                perror("malloc()");
194
192
                exit(1);
195
193
        }
196
 
        memcpy(d, old, sizeof(struct dict));
 
194
        memcpy(d, old, sizeof(Dict));
197
195
        for (i = 0; i < DICTTABLESIZE; i++) {   /* better use memset()? */
198
196
                struct dict_entry *de_old;
199
197
                struct dict_entry **de_new;