-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mm_test | ||
core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# WARNING | ||
# | ||
# You should NOT edit this file, to change compiler flags, defines, etc. | ||
# The hw3 autograder will replace this Makefile with a fresh copy. | ||
# | ||
SRCS=mm_alloc.c mm_test.c | ||
EXECUTABLES=mm_test | ||
|
||
CC=gcc | ||
CFLAGS=-g -Wall | ||
LDFLAGS= | ||
|
||
OBJS=$(SRCS:.c=.o) | ||
|
||
all: $(EXECUTABLES) | ||
|
||
$(EXECUTABLES): $(OBJS) | ||
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@ | ||
|
||
.c.o: | ||
$(CC) $(CFLAGS) -c $< -o $@ | ||
|
||
clean: | ||
rm -rf $(EXECUTABLES) $(OBJS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* mm_alloc.c | ||
* | ||
* Stub implementations of the mm_* routines. | ||
*/ | ||
|
||
#include "mm_alloc.h" | ||
#include <stdlib.h> | ||
|
||
void *mm_malloc(size_t size) { | ||
/* YOUR CODE HERE */ | ||
return NULL; | ||
} | ||
|
||
void *mm_realloc(void *ptr, size_t size) { | ||
/* YOUR CODE HERE */ | ||
return NULL; | ||
} | ||
|
||
void mm_free(void *ptr) { | ||
/* YOUR CODE HERE */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* mm_alloc.h | ||
* | ||
* Exports a clone of the interface documented in "man 3 malloc". | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdlib.h> | ||
|
||
void *mm_malloc(size_t size); | ||
void *mm_realloc(void *ptr, size_t size); | ||
void mm_free(void *ptr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* A simple test harness for memory alloction. You should augment this with your | ||
* own tests. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include "mm_alloc.h" | ||
|
||
int main(int argc, char **argv) { | ||
int *data; | ||
data = (int *) mm_malloc(4); | ||
data[0] = 1; | ||
mm_free(data); | ||
printf("malloc() basic test passed!\n"); | ||
return 0; | ||
} |