Mercurial > hg > Game > Cerium
view TaskManager/kernel/memory/MemList.cc @ 369:93b33cecba37 draft
change TaskManager.cc
author | aaa |
---|---|
date | Tue, 28 Jul 2009 19:42:59 +0900 |
parents | 1a80a2aa696c |
children | 4748fd7dcd89 |
line wrap: on
line source
/*! MemList は空にならない。最低1個は要素が入っていて 1個目は特別扱いする。getFirst すると first->next を返す */ #include <stdio.h> #include "MemList.h" /*! 最初の1個は特別扱いなので、それの後に追加していく */ void MemList::addFirst(MemorySegment* e) { e->prev = first; e->next = first->next; first->next->prev = e; first->next = e; } void MemList::addLast(MemorySegment* e) { e->next = first; e->prev = last; last->next = e; last = e; } MemorySegment* MemList::getFirst() { return first->next; } MemorySegment* MemList::getLast() { return last; } int MemList::remove(MemorySegment* e) { e->prev->next = e->next; if (e->next != NULL) { e->next->prev = e->prev; } e->prev = NULL; e->next = NULL; return 1; } void MemList::moveToFirst(MemorySegment* e) { remove(e); addFirst(e); }