-
Notifications
You must be signed in to change notification settings - Fork 0
/
537malloc.h
71 lines (68 loc) · 2.21 KB
/
537malloc.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
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
////////////////////////////////////////////////////////////////////////////////
// Main File: testcases
// This File: 537malloc.h
// Other Files: 537malloc.c range_tree.c range_tree.h
// linkedlist.c linkedlist.h
// Semester: CS 537 Fall 2018
//
// Author: Youmin Han
// Email: youmin.han@wisc.edu
// CS Login: youmin
//
// Author: Xianjie Zheng
// Email: xzheng97@wisc.edu
// CS Login: xianjie
//
/////////////////////////// OTHER SOURCES OF HELP //////////////////////////////
// fully acknowledge and credit all sources of help,
// other than Instructors and TAs.
//
// Persons: NULL
//
// Online sources: NULL
//
//////////////////////////// 80 columns wide ///////////////////////////////////
#ifndef _537malloc_h
#define _537malloc_h
#include <sys/types.h>
#include "range_tree.h"
#include "linkedlist.h"
/*
* In addition to actually allocating the memory by calling malloc(), this
* function will record a tuple (addri, leni), for the memory that you
* allocate in the heap.
*
* @param size: memory size that user want to allocate
* @return: address of that memory
*/
void *malloc537(size_t size);
/*
* This function checks to see the address range specified by address ptr
* and length size are fully within a range allocated by malloc537() and
* memory not yet freed by free537().
*
* @param ptr: input starting address
* size: memory size
*
*/
void memcheck537(void *ptr, size_t size);
/*
* This function will first check to make sure that freeing the memory
* specified by ptr makes sense, then will call free() to do the actual free.
*
* @param ptr: input starting address
*
*/
void free537(void *ptr);
/*
* If ptr is NULL,then this follows the specification of malloc537() above.
* If size is zero and ptr is not NULL,then this follows the specification of
* free537() above. Otherwise, in addition to changing the memory allocation by
* calling realloc(), this function will first check to see if there was a tuple.
*
* @param ptr: input starting address
* size: input size
* @return realloc address
*/
void *realloc537(void *ptr, size_t size);
#endif