Subversion Repositories Kolibri OS

Rev

Rev 1238 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1238 vkos 1
/*******************************************************************************
2
 *   Copyright (C) 2009 Vasiliy Kosenko                                        *
3
 *                                                                             *
4
 *   This program is free software; you can redistribute it and/or modify      *
5
 *   it under the terms of the GNU General Public License as published by      *
6
 *   the Free Software Foundation; either version 3 of the License, or         *
7
 *   (at your option) any later version.                                       *
8
 *                                                                             *
9
 *   This program is distributed in the hope that it will be useful,           *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of            *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
12
 *   GNU General Public License for more details.                              *
13
 *                                                                             *
14
 *   You should have received a copy of the GNU General Public License         *
15
 *   along with this program; if not, write to the Free Software               *
16
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
17
 *******************************************************************************/
18
 
19
#ifndef _HEAP_H_
20
#define _HEAP_H_
21
 
22
#include "defs.h"
23
 
24
#define PAGE_SIZE 0x1000
25
 
26
typedef struct MemBlock {
27
	struct MemBlock *next;
28
	struct MemBlock *previos;
29
	unsigned long nblocks;
30
	unsigned long align;
31
} MemBlock;
32
 
33
typedef struct Heap {
34
	struct MemBlock *free;
35
	struct MemBlock *allocated;
36
	void *(*alloc)(struct Heap *heap, int nbytes);
37
} Heap;
38
 
39
void *halMemAlloc(Heap *wheap, unsigned long n);
40
void halMemFree(Heap *wheap, void *addr);
41
MemBlock *halMemBlockAdd(MemBlock *heap, MemBlock *unit, bool optimize);
42
MemBlock *halMemBlockRemove(MemBlock *unit);
43
 
44
void halMemHeapInit(Heap *wheap, void *(*alloc)(Heap *heap, int nbytes), void *st_addr, int size);
45
 
46
#endif