normm
This commit is contained in:
parent
71d3fde169
commit
80fedbeb03
5 changed files with 16 additions and 27 deletions
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <gtertysh@student.unit.ua> +#+ +:+ +#+ */
|
/* By: gtertysh <gtertysh@student.unit.ua> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/05/06 22:37:07 by foton #+# #+# */
|
/* Created: 2019/05/06 22:37:07 by foton #+# #+# */
|
||||||
/* Updated: 2019/05/06 22:40:18 by gtertysh ### ########.fr */
|
/* Updated: 2019/05/08 19:45:18 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <gtertysh@student.unit.ua> +#+ +:+ +#+ */
|
/* By: gtertysh <gtertysh@student.unit.ua> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/05/06 22:35:57 by foton #+# #+# */
|
/* Created: 2019/05/06 22:35:57 by foton #+# #+# */
|
||||||
/* Updated: 2019/05/07 22:06:49 by gtertysh ### ########.fr */
|
/* Updated: 2019/05/08 19:44:07 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <gtertysh@student.unit.ua> +#+ +:+ +#+ */
|
/* By: gtertysh <gtertysh@student.unit.ua> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/05/06 22:35:48 by foton #+# #+# */
|
/* Created: 2019/05/06 22:35:48 by foton #+# #+# */
|
||||||
/* Updated: 2019/05/07 00:25:13 by gtertysh ### ########.fr */
|
/* Updated: 2019/05/08 19:44:41 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/04 15:17:18 by gtertysh #+# #+# */
|
/* Created: 2016/12/04 15:17:18 by gtertysh #+# #+# */
|
||||||
/* Updated: 2016/12/04 15:24:55 by gtertysh ### ########.fr */
|
/* Updated: 2019/05/08 19:48:54 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gtertysh <gtertysh@student.unit.ua> +#+ +:+ +#+ */
|
/* By: gtertysh <gtertysh@student.unit.ua> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/05/06 22:35:37 by foton #+# #+# */
|
/* Created: 2019/05/06 22:35:37 by foton #+# #+# */
|
||||||
/* Updated: 2019/05/07 22:44:42 by gtertysh ### ########.fr */
|
/* Updated: 2019/05/08 19:47:45 by gtertysh ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ int returns_not_null_pointer(void)
|
||||||
g_base.next = &g_base;
|
g_base.next = &g_base;
|
||||||
ptr = malloc(10);
|
ptr = malloc(10);
|
||||||
_IS(ptr != NULL);
|
_IS(ptr != NULL);
|
||||||
|
|
||||||
ptr = ptr - 1;
|
ptr = ptr - 1;
|
||||||
_IS(ptr->is_free == 0);
|
_IS(ptr->is_free == 0);
|
||||||
_IS(ptr->size == 10 + sizeof(t_chunk));
|
_IS(ptr->size == 10 + sizeof(t_chunk));
|
||||||
|
@ -48,25 +47,19 @@ int free_concatenates_adjacent_blocks(void)
|
||||||
g_base.next = &g_base;
|
g_base.next = &g_base;
|
||||||
ptr = malloc(10);
|
ptr = malloc(10);
|
||||||
next_malloc = malloc(10);
|
next_malloc = malloc(10);
|
||||||
|
|
||||||
ptr -= 1;
|
ptr -= 1;
|
||||||
next_malloc -= 1;
|
next_malloc -= 1;
|
||||||
|
|
||||||
free(ptr + 1);
|
free(ptr + 1);
|
||||||
|
|
||||||
_IS(ptr->is_free == 1);
|
_IS(ptr->is_free == 1);
|
||||||
_IS(ptr->prev == next_malloc);
|
_IS(ptr->prev == next_malloc);
|
||||||
_IS(next_malloc->is_free == 0);
|
_IS(next_malloc->is_free == 0);
|
||||||
_IS(next_malloc->next == ptr);
|
_IS(next_malloc->next == ptr);
|
||||||
_IS(next_malloc->prev->prev == NULL);
|
_IS(next_malloc->prev->prev == NULL);
|
||||||
|
|
||||||
heap = next_malloc->prev;
|
heap = next_malloc->prev;
|
||||||
free(next_malloc + 1);
|
free(next_malloc + 1);
|
||||||
|
|
||||||
_IS(heap->is_free == 1);
|
_IS(heap->is_free == 1);
|
||||||
_IS(heap->prev == NULL);
|
_IS(heap->prev == NULL);
|
||||||
_IS(heap->next == NULL);
|
_IS(heap->next == NULL);
|
||||||
|
|
||||||
_END("free_concatenates_adjacent_blocks");
|
_END("free_concatenates_adjacent_blocks");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,12 +81,9 @@ int malloc_creates_new_arena(void)
|
||||||
second_arena_chunk = malloc(TINY);
|
second_arena_chunk = malloc(TINY);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
_IS(g_base.next->next == &g_base);
|
_IS(g_base.next->next == &g_base);
|
||||||
_IS(g_base.next->type == TINY);
|
_IS(g_base.next->type == TINY);
|
||||||
|
|
||||||
second_arena_chunk = malloc(TINY);
|
second_arena_chunk = malloc(TINY);
|
||||||
|
|
||||||
_IS(g_base.next->next != &g_base);
|
_IS(g_base.next->next != &g_base);
|
||||||
_IS(g_base.next->type == TINY);
|
_IS(g_base.next->type == TINY);
|
||||||
_IS(g_base.next->heap->next == second_arena_chunk - 1);
|
_IS(g_base.next->heap->next == second_arena_chunk - 1);
|
||||||
|
@ -108,7 +98,6 @@ int realloc_return_same_pointer(void)
|
||||||
g_base.next = &g_base;
|
g_base.next = &g_base;
|
||||||
ptr = malloc(20);
|
ptr = malloc(20);
|
||||||
new_ptr = realloc(ptr, 10);
|
new_ptr = realloc(ptr, 10);
|
||||||
|
|
||||||
_IS(ptr == new_ptr);
|
_IS(ptr == new_ptr);
|
||||||
_END("realloc_return_same_pointer");
|
_END("realloc_return_same_pointer");
|
||||||
}
|
}
|
||||||
|
@ -120,5 +109,5 @@ int main(void)
|
||||||
_SHOULD(free_concatenates_adjacent_blocks);
|
_SHOULD(free_concatenates_adjacent_blocks);
|
||||||
_SHOULD(malloc_creates_new_arena);
|
_SHOULD(malloc_creates_new_arena);
|
||||||
_SHOULD(realloc_return_same_pointer);
|
_SHOULD(realloc_return_same_pointer);
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
Loading…
Reference in a new issue