Skip to main content
aboutsummaryrefslogblamecommitdiffstats
blob: 13a9faee90837a6b0d582b250ffccede8139d50f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                                                 



                                                                                       
                                                                                        

















                                                                   








                                                             




                                        


                                                                  
                                               
                              
                                            



                            
/*******************************************************************************
 * 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"

/**
 * this macro computes the memory aligned value for a given size. It uses the ALIGNMENT
 * defined in etDatatypes.h
 */
#define MEM_CEIL(n)          ((n)+((etALIGNMENT-((n)&(etALIGNMENT-1)))&(etALIGNMENT-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);

typedef struct etMemoryStatistics {
	const char* name;
	etUInt32 maxUsed;
	etUInt32 nFailingRequests;
	struct etMemoryStatistics* next;
}
etMemoryStatistics;

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

	/** statistical data made available through the runtime */
	etMemoryStatistics statistics;

	/** the configured allocation method */
	etMemory_alloc* alloc;
	/** the configured freeing method */
	etMemory_free* free;
} etMemory;

#endif /* _ETMEMORY_H_ */

Back to the top