-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructs.h
More file actions
72 lines (64 loc) · 1.36 KB
/
structs.h
File metadata and controls
72 lines (64 loc) · 1.36 KB
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
/* Copyright 2023 Razvan-Constantin Rus */
#ifndef STRUCTS_H_
#define STRUCTS_H_
#include <stdlib.h>
#include <stdio.h>
typedef struct ll_node_t ll_node_t;
struct ll_node_t
{
// Stored data
void* data;
// Next element
struct ll_node_t* next;
};
typedef struct linked_list_t linked_list_t;
struct linked_list_t
{
// Fires element
ll_node_t* head;
// Size of the data in bytes
unsigned int data_size;
// number of nodes
unsigned int size;
};
typedef struct info info;
struct info {
void *key;
void *value;
};
typedef struct hashtable_t hashtable_t;
struct hashtable_t {
// Linked list array
linked_list_t **buckets;
// Number of entries
unsigned int size;
// Linked list array size
unsigned int hmax;
// Hashing function
unsigned int (*hash_function)(void*);
// Compare function
int (*compare_function)(void*, void*);
// Free function for data
void (*key_val_free_function)(void*);
};
typedef struct server_memory server_memory;
struct server_memory {
// Hashtable
hashtable_t *memory;
// Server_id
int idx;
};
typedef struct load_balancer load_balancer;
struct load_balancer {
// Servers array
server_memory **servers;
// Size of the servers array
unsigned int size;
// Number of servers
unsigned int count;
// Value 'till next replica (100000)
unsigned int rep;
// Hashing function for servers
unsigned int (*hash)(void *);
};
#endif // STRUCTS_H_