* Renamed memmgr.c|h to memory_manager.c|h.
* The functions now check the acquire_sem() result. * mem_freetag() will return an status code now, too. * Moved the mem_block and mem_info definitions into the source file; no reason to have them public. * You can now give the memory manager a name which it will use for its heap area and lock. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17221 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2002, Thomas Kurschel
|
||||
|
||||
|
||||
Part of Radeon kernel driver
|
||||
|
||||
Memory manager used for graphics mem
|
||||
*/
|
||||
|
||||
#ifndef _MEMMGR_H
|
||||
#define _MEMMGR_H
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
|
||||
// allocated memory block
|
||||
typedef struct mem_block {
|
||||
struct mem_block *prev, *next;
|
||||
uint32 base;
|
||||
uint32 size;
|
||||
void *tag;
|
||||
bool alloced;
|
||||
} mem_block;
|
||||
|
||||
|
||||
// memory heap
|
||||
typedef struct mem_info {
|
||||
mem_block *first;
|
||||
area_id heap_area;
|
||||
uint32 block_size;
|
||||
sem_id lock;
|
||||
mem_block *heap;
|
||||
mem_block *unused;
|
||||
uint32 heap_entries;
|
||||
} mem_info;
|
||||
|
||||
|
||||
mem_info *mem_init( uint32 start, uint32 len, uint32 block_size, uint32 heap_entries );
|
||||
void mem_destroy( mem_info *mem );
|
||||
status_t mem_alloc( mem_info *mem, uint32 size, void *tag, uint32 *block, uint32 *offset );
|
||||
status_t mem_free( mem_info *mem, uint32 block_id, void *tag );
|
||||
void mem_freetag( mem_info *mem, void *tag );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc.
|
||||
* Copyright 2002, Thomas Kurschel.
|
||||
*
|
||||
* Distributed under the terms of the MIT license.
|
||||
*/
|
||||
#ifndef _MEMORY_MANAGER_H
|
||||
#define _MEMORY_MANAGER_H
|
||||
|
||||
/** Memory manager used for graphics mem */
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
|
||||
typedef struct mem_info mem_info;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
mem_info *mem_init(const char *name, uint32 start, uint32 length, uint32 blockSize,
|
||||
uint32 heapEntries);
|
||||
void mem_destroy(mem_info *mem);
|
||||
status_t mem_alloc(mem_info *mem, uint32 size, void *tag, uint32 *blockID, uint32 *offset);
|
||||
status_t mem_free(mem_info *mem, uint32 blockID, void *tag);
|
||||
status_t mem_freetag(mem_info *mem, void *tag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MEMORY_MANAGER_H */
|
||||
Reference in New Issue
Block a user