Fixed performance of getSz
parent
921a49c0fc
commit
ad1dd76932
4
Makefile
4
Makefile
|
@ -2,8 +2,8 @@
|
||||||
# Students' Makefile for the Malloc Lab
|
# Students' Makefile for the Malloc Lab
|
||||||
#
|
#
|
||||||
CC = gcc
|
CC = gcc
|
||||||
# CFLAGS = -Wall -O2 -m32
|
CFLAGS = -Wall -O2 -m32
|
||||||
CFLAGS = -Wall -O0 -m32 -g03 -pg
|
# CFLAGS = -Wall -O0 -m32 -g03 -pg
|
||||||
|
|
||||||
OBJS = mdriver.o mm.o memlib.o fsecs.o fcyc.o clock.o ftimer.o
|
OBJS = mdriver.o mm.o memlib.o fsecs.o fcyc.o clock.o ftimer.o
|
||||||
|
|
||||||
|
|
13
mm.c
13
mm.c
|
@ -164,18 +164,17 @@ static void *place(void *ptr, size_t asize);
|
||||||
@param[in] asize size class to look for in segregated list
|
@param[in] asize size class to look for in segregated list
|
||||||
@result Size class (i.e. index of segregated list)
|
@result Size class (i.e. index of segregated list)
|
||||||
*/
|
*/
|
||||||
static int getSzClass(size_t asize);
|
static inline int getSzClass(size_t asize);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////// HELPER FUNCTIONS ///////////////////////////////
|
/////////////////////////////// HELPER FUNCTIONS ///////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static int getSzClass(size_t asize) {
|
static inline int getSzClass(size_t asize) {
|
||||||
for (size_t i = 0; i < LISTSIZE; ++i) {
|
int i;
|
||||||
if (asize == (1 << i)) {
|
for (i = 0; (i < LISTSIZE-1) && (asize > 1); ++i) {
|
||||||
return i;
|
asize >>= 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return LISTSIZE-1;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *extend_heap(size_t size)
|
static void *extend_heap(size_t size)
|
||||||
|
|
Loading…
Reference in New Issue