forked from embedded2015/phonebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phonebook_opt.h
43 lines (37 loc) · 929 Bytes
/
phonebook_opt.h
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
#ifndef _PHONEBOOK_H
#define _PHONEBOOK_H
#define TABLE_SIZE 5393
#define MAX_LAST_NAME_SIZE 16
typedef struct _DETAIL_BOOK_ENTRY {
char firstName[16];
char email[16];
char phone[10];
char cell[10];
char addr1[16];
char addr2[16];
char city[16];
char state[2];
char zip[5];
} detail ;
typedef struct __PHONE_BOOK_ENTRY {
char lastName[MAX_LAST_NAME_SIZE];
detail *more;
struct __PHONE_BOOK_ENTRY *pNext;
} entry;
typedef struct _POOL_ {
entry *start;
entry *end;
entry *now;
} pool;
typedef struct __Hash_Table {
entry **list;
} hashtable ;
void create_pool(pool *mem_pool);
entry *mem_allocate(pool *mem_pool);
void *mem_free(pool *mem_pool);
void destroy_pool(pool *mem_pool);
void appendhash(char lastName[], hashtable *ht, pool *mem_pool);
entry *findhash(char lastName[], hashtable *ht);
hashtable *Create_Hash_Table();
int hash(char lastName[]);
#endif