Skip to content

Commit 5d1b63e

Browse files
committed
leader: try fix segvfault
1 parent b967b45 commit 5d1b63e

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/network/leader.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ size_t alloc_memory(size_t size, struct leader_resources *l_r) {
4747
if (0 == b->free && b->id != l_r->id && !is_in_dead_list(l_r, b->id)) {
4848
if (size == b->size) {
4949
b->free = 1;
50-
struct allocation *a = malloc(32 + sizeof(struct allocation));
50+
struct allocation *a = malloc(60 + sizeof(struct allocation));
5151
a->number_parts = 1;
5252
a->v_address_start = b->virtual_address;
5353
a->parts = malloc(34 + (a->number_parts * sizeof(struct allocation *)));
@@ -59,7 +59,7 @@ size_t alloc_memory(size_t size, struct leader_resources *l_r) {
5959
b->free = 1;
6060
b = split_block_u(b, size);
6161
if (b) {
62-
struct allocation *a = malloc(32 + sizeof(struct allocation));
62+
struct allocation *a = malloc(60 + sizeof(struct allocation));
6363
a->number_parts = 1;
6464
a->v_address_start = b->virtual_address;
6565
a->parts = malloc(34 + (a->number_parts * sizeof(struct allocation *)));
@@ -76,7 +76,7 @@ size_t alloc_memory(size_t size, struct leader_resources *l_r) {
7676
}
7777
}
7878
// Multi - Parts
79-
struct allocation *a = malloc(32 + sizeof(struct allocation));
79+
struct allocation *a = malloc(60 + sizeof(struct allocation));
8080
a->number_parts = 0;
8181
a->parts = NULL;
8282
a->v_address_start = SIZE_MAX;
@@ -98,7 +98,7 @@ size_t alloc_memory(size_t size, struct leader_resources *l_r) {
9898
if (a->v_address_start == SIZE_MAX)
9999
a->v_address_start = b->virtual_address;
100100
a->number_parts++;
101-
a->parts = realloc(a->parts, 34 + (a->number_parts * sizeof(struct allocation *)));
101+
a->parts = realloc(a->parts, (4 + a->number_parts) * sizeof(struct allocation *));
102102
a->parts[a->number_parts - 1] = b;
103103
}
104104
b = b->next;

src/network/leader_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ struct allocation *give_for_v_address(struct leader_resources *l_r, size_t v_add
6666
}
6767

6868
struct leader_resources *generate_leader_resources(size_t nb_nodes, size_t id) {
69-
struct leader_resources *l_r = malloc(128);
69+
struct leader_resources *l_r = malloc(sizeof(struct leader_resources) + 200);
7070
l_r->leader_blks = init_nodes_same_size(nb_nodes, DEF_NODE_SIZE);
7171
l_r->leader_command_queue = NULL;
7272
l_r->leader_reg = generate_allocs(4);
7373
l_r->id = id;
7474
l_r->max_memory = nb_nodes * DEF_NODE_SIZE - (DEF_NODE_SIZE); // minus leader
7575
l_r->availaible_memory = l_r->max_memory;
76-
l_r->dead_list = malloc(sizeof(struct dead_list) + 34);
76+
l_r->dead_list = malloc(sizeof(struct dead_list) + 70);
7777
l_r->dead_list->dead_list = calloc(nb_nodes + 10, sizeof(unsigned short));
7878
l_r->dead_list->max = nb_nodes;
7979
return l_r;

0 commit comments

Comments
 (0)