| 1 | /******************************************************************** |
|---|
| 2 | * |
|---|
| 3 | * memchain.h - Utility for associating allocated memory |
|---|
| 4 | * |
|---|
| 5 | * Copyright 1997-2002 TeraLogic, Inc. |
|---|
| 6 | * All Rights Reserved |
|---|
| 7 | * |
|---|
| 8 | * memChainCreate: Creates a memChain object. |
|---|
| 9 | * (O) instance: returns the memChain instance. |
|---|
| 10 | * (I) memLimit: Optionally limits the memory allocated with a |
|---|
| 11 | * memChain. Set to 0xFFFFFFFF for no limit. |
|---|
| 12 | * |
|---|
| 13 | * memChainDestroy: Destroys a memChain object. |
|---|
| 14 | * (I) instance: The memChain instance. |
|---|
| 15 | * |
|---|
| 16 | * memChainAlloc: Allocates a memory block and associates it with |
|---|
| 17 | * the specified memChain object. |
|---|
| 18 | * (I) instance: The memChain instance. |
|---|
| 19 | * (I) size: Size of memory (in bytes) requested. |
|---|
| 20 | * |
|---|
| 21 | * _Id: memchain.h,v 1.1 2002/06/10 17:20:08 tvogt Exp |
|---|
| 22 | ********************************************************************/ |
|---|
| 23 | |
|---|
| 24 | #ifndef _memchain_h |
|---|
| 25 | #define _memchain_h |
|---|
| 26 | |
|---|
| 27 | #include "dsthallocal.h" |
|---|
| 28 | |
|---|
| 29 | #ifdef __cplusplus |
|---|
| 30 | extern "C" { |
|---|
| 31 | #endif |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | /* user-defined malloc/free */ |
|---|
| 37 | typedef void* (*myMalloc_f) (unsigned int size, const char *strFunctionName, int nLine); |
|---|
| 38 | typedef void (*myFree_f) (void *block, const char *strFunctionName, int nLine); |
|---|
| 39 | |
|---|
| 40 | /* memChain Setup Info */ |
|---|
| 41 | typedef struct memChainSetup { |
|---|
| 42 | DS_U32 memLimit; |
|---|
| 43 | myMalloc_f Malloc; |
|---|
| 44 | myFree_f Free; |
|---|
| 45 | } memChainSetup_t, *memChainSetupPtr_t; |
|---|
| 46 | |
|---|
| 47 | typedef struct memChainHead* memId_t; |
|---|
| 48 | |
|---|
| 49 | /* API */ |
|---|
| 50 | #define memChainCreate(a, b) _memChainCreate((a), (b), __func__, __LINE__) |
|---|
| 51 | #define memChainDestroy(a) _memChainDestroy((a), __func__, __LINE__) |
|---|
| 52 | #define memChainAlloc(a, b) _memChainAlloc((a), (b), __func__, __LINE__) |
|---|
| 53 | |
|---|
| 54 | DHL_RESULT _memChainCreate (memId_t *memId, memChainSetupPtr_t setupPtr, const char *func, int nLine); |
|---|
| 55 | DHL_RESULT _memChainDestroy (memId_t memId, const char *func, int nLine); |
|---|
| 56 | void* _memChainAlloc (memId_t memId, DS_U32 size, const char *func, int nLine); |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | #ifdef __cplusplus |
|---|
| 61 | } |
|---|
| 62 | #endif |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | #endif /* _memchain_h */ |
|---|
| 67 | /******************************************************************** |
|---|
| 68 | * _Log: memchain.h,v |
|---|
| 69 | * Revision 1.1 2002/06/10 17:20:08 tvogt |
|---|
| 70 | * First checkin of TL9xx Transport Driver |
|---|
| 71 | * |
|---|
| 72 | * |
|---|
| 73 | * TL8xx Derived Revision 1.6.12.1 2002/01/12 11:09:12 neelakan |
|---|
| 74 | ********************************************************************/ |
|---|