Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 32683d8dd15af49aec2ec65335aab3d27d8852ed (plain) (blame)
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
/*******************************************************************************
 * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * CONTRIBUTORS:
 * 		Henrik Rentz-Reichert (initial contribution)
 *
 *******************************************************************************/

#ifndef _ETMEMORY_H_
#define _ETMEMORY_H_

#include "etDatatypes.h"

#define CEIL_ALIGN(n)          ((n)+((ALIGNMENT-((n)&(ALIGNMENT-1)))&(ALIGNMENT-1)))

struct etMemory;

/**
 * allocates memory from the heap
 *
 * \param heap pointer to the heap memory
 * \param size the size of the requested memory in bytes
 */
typedef void* etMemory_alloc(struct etMemory* heap, etUInt16 size);

/**
 * frees memory previously allocated from the heap
 *
 * \param heap pointer to the heap memory
 * \param obj pointer to the memory returned
 * \param size the size in bytes of the memory returned
 */
typedef void etMemory_free(struct etMemory* heap, void* obj, etUInt16 size);

typedef struct etMemory {
	/** size of the heap in bytes */
	etUInt32 size;

	etMemory_alloc* alloc;
	etMemory_free* free;
} etMemory;

#endif /* _ETMEMORY_H_ */

Back to the top