VirtualBox

Changeset 288 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Jan 25, 2007 5:14:15 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
17834
Message:

debugged the heap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/heap.h

    r283 r288  
    3333/** Pointer to a handle to a simple heap. */
    3434typedef RTHEAPSIMPLE *PRTHEAPSIMPLE;
     35
     36/** NIL simple heap handle. */
     37#define NIL_RTHEAPSIMPLE    ((RTHEAPSIMPLE)0)
    3538/* <<< types.h */
    3639
     
    3942/**
    4043 * Initializes the heap.
    41  * 
     44 *
    4245 * @returns IPRT status code on success.
    4346 * @param   pHeap       Where to store the heap anchor block on success.
     
    4952/**
    5053 * Merge two simple heaps into one.
    51  * 
     54 *
    5255 * The requiremet is of course that they next two each other memory wise.
    53  * 
     56 *
    5457 * @returns IPRT status code on success.
    5558 * @param   pHeap       Where to store the handle to the merged heap on success.
    5659 * @param   Heap1       Handle to the first heap.
    5760 * @param   Heap2       Handle to the second heap.
     61 * @remark  This API isn't implemented yet.
    5862 */
    5963RTDECL(int) RTHeapSimpleMerge(PRTHEAPSIMPLE pHeap, RTHEAPSIMPLE Heap1, RTHEAPSIMPLE Heap2);
     
    6165/**
    6266 * Allocates memory from the specified simple heap.
    63  * 
     67 *
    6468 * @returns Pointer to the allocated memory block on success.
    6569 * @returns NULL if the request cannot be satisfied. (A VERR_NO_MEMORY condition.)
    66  * 
     70 *
    6771 * @param   Heap        The heap to allocate the memory on.
    6872 * @param   cb          The requested heap block size.
     
    7478/**
    7579 * Allocates zeroed memory from the specified simple heap.
    76  * 
     80 *
    7781 * @returns Pointer to the allocated memory block on success.
    7882 * @returns NULL if the request cannot be satisfied. (A VERR_NO_MEMORY condition.)
    79  * 
     83 *
    8084 * @param   Heap        The heap to allocate the memory on.
    8185 * @param   cb          The requested heap block size.
     
    8690
    8791/**
     92 * Reallocates / Allocates / Frees a heap block.
     93 *
     94 * @param   Heap        The heap. This is optional and will only be used for strict assertions.
     95 * @param   pv          The heap block returned by RTHeapSimple. If NULL it behaves like RTHeapSimpleAlloc().
     96 * @param   cbNew       The new size of the heap block. If NULL it behaves like RTHeapSimpleFree().
     97 * @param   cbAlignment The requested heap block alignment. Pass 0 for default alignment.
     98 *                      Must be a power of 2.
     99 * @remark  This API isn't implemented yet.
     100 */
     101RTDECL(void *) RTHeapSimpleRealloc(RTHEAPSIMPLE Heap, void *pv, size_t cbNew, size_t cbAlignment);
     102
     103/**
     104 * Reallocates / Allocates / Frees a heap block, zeroing any new bits.
     105 *
     106 * @param   Heap        The heap. This is optional and will only be used for strict assertions.
     107 * @param   pv          The heap block returned by RTHeapSimple. If NULL it behaves like RTHeapSimpleAllocZ().
     108 * @param   cbNew       The new size of the heap block. If NULL it behaves like RTHeapSimpleFree().
     109 * @param   cbAlignment The requested heap block alignment. Pass 0 for default alignment.
     110 *                      Must be a power of 2.
     111 * @remark  This API isn't implemented yet.
     112 */
     113RTDECL(void *) RTHeapSimpleReallocZ(RTHEAPSIMPLE Heap, void *pv, size_t cbNew, size_t cbAlignment);
     114
     115/**
    88116 * Frees memory allocated from a simple heap.
    89  * 
     117 *
    90118 * @param   Heap    The heap. This is optional and will only be used for strict assertions.
    91119 * @param   pv      The heap block returned by RTHeapSimple
     
    93121RTDECL(void) RTHeapSimpleFree(RTHEAPSIMPLE Heap, void *pv);
    94122
    95 #ifdef DEBUG
    96123/**
    97  * Dumps the hypervisor heap to the (default) log.
    98  *
     124 * Gets the size of the specified heap block.
     125 *
     126 * @returns The actual size of the heap block.
     127 * @returns 0 if \a pv is NULL or it doesn't point to a valid heap block. An invalid \a pv
     128 *          can also cause traps or trigger assertions.
     129 * @param   Heap    The heap. This is optional and will only be used for strict assertions.
     130 * @param   pv      The heap block returned by RTHeapSimple
     131 */
     132RTDECL(size_t) RTHeapSimpleSize(RTHEAPSIMPLE Heap, void *pv);
     133
     134/**
     135 * Gets the size of the heap.
     136 *
     137 * This size includes all the internal heap structures. So, even if the heap is
     138 * empty the RTHeapSimpleGetFreeSize() will never reach the heap size returned
     139 * by this function.
     140 *
     141 * @returns The heap size.
     142 * @returns 0 if heap was safely detected as being bad.
     143 * @param   Heap    The heap.
     144 */
     145RTDECL(size_t) RTHeapSimpleGetHeapSize(RTHEAPSIMPLE Heap);
     146
     147/**
     148 * Returns the sum of all free heap blocks.
     149 *
     150 * This is the amount of memory you can theoretically allocate
     151 * if you do allocations exactly matching the free blocks.
     152 *
     153 * @returns The size of the free blocks.
     154 * @returns 0 if heap was safely detected as being bad.
     155 * @param   Heap    The heap.
     156 */
     157RTDECL(size_t) RTHeapSimpleGetFreeSize(RTHEAPSIMPLE Heap);
     158
     159/**
     160 * Printf like callbaclk function for RTHeapSimpleDump.
     161 * @param   pszFormat   IPRT format string.
     162 * @param   ...         Format arguments.
     163 */
     164typedef DECLCALLBACK(void) FNRTHEAPSIMPLEPRINTF(const char *pszFormat, ...);
     165/** Pointer to a FNRTHEAPSIMPLEPRINTF function. */
     166typedef FNRTHEAPSIMPLEPRINTF *PFNRTHEAPSIMPLEPRINTF;
     167
     168/**
     169 * Dumps the hypervisor heap.
     170 *
    99171 * @param   Heap        The heap handle.
     172 * @param   pfnPrintf   Printf like function that groks IPRT formatting.
    100173 */
    101 RTDECL(void) RTHeapSimpleDump(RTHEAPSIMPLE Heap);
    102 #endif
    103 
     174RTDECL(void) RTHeapSimpleDump(RTHEAPSIMPLE Heap, PFNRTHEAPSIMPLEPRINTF pfnPrintf);
    104175
    105176__END_DECLS
    106177
    107 #endif 
     178#endif
    108179
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette