From 78eb4ef51d705cb5214258946fb4e9981d49a9b5 Mon Sep 17 00:00:00 2001 From: kwanju <rhkswn123@ajou.ac.kr> Date: Thu, 14 Jun 2018 00:25:27 +0900 Subject: [PATCH] v2 --- alloc.c | 17 +++++++++++++---- alloc.h | 6 +++++- main.c | 3 +++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/alloc.c b/alloc.c index b0f351d..6ad21ac 100644 --- a/alloc.c +++ b/alloc.c @@ -1,5 +1,9 @@ -#include "alloc.h"즈 -#define MSIZE sizeof(meta_struct)-4 +#include "alloc.h" +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> + +#define MSIZE sizeof(meta)-4 void* total = 0; void* base = 0; @@ -7,8 +11,13 @@ void* end = 0; void* cur = 0; int fit;//0 1 2 +void *m_malloc(size_t size); +void *m_realloc(void* ptr, size_t size); +void m_free(void* ptr); +meta* search(void* ptr, size_t size); + meta* search(void* ptr, size_t size){//current pointer - mata* index = base; + meta* index = base; meta* result = 0; if(base == ptr) @@ -78,7 +87,7 @@ void *m_malloc(size_t size){ return target->data; } -void m_free(void *ptr){ +void m_free(void* ptr){ meta* target; target = ptr - MSIZE; target->free = 1; diff --git a/alloc.h b/alloc.h index 82597d4..fe16133 100644 --- a/alloc.h +++ b/alloc.h @@ -1,7 +1,11 @@ #ifndef _ALLOC_H_ #define _ALLOC_H_ +#include <stdio.h> +#include <stdint.h> +#include <stddef.h> +#include <stdbool.h> -typedef struct meta_struct { +typedef struct meta { //double linked list struct meta* prev; struct meta* next; diff --git a/main.c b/main.c index 51b40c8..890a3ac 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,7 @@ #include "alloc.h" +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> extern int fit; -- GitLab