malloc.mh

来自「开放源码的编译器open watcom 1.6.0版的源代码」· MH 代码 · 共 173 行

MH
173
字号
/*
 *  malloc.h    Memory allocation functions
 *
:include crwat.sp
 */
#ifndef _MALLOC_H_INCLUDED
#define _MALLOC_H_INCLUDED
:include readonly.sp
:include cpluspro.sp

#ifndef _COMDEF_H_INCLUDED
 #include <_comdef.h>
#endif

:include pshpackl.sp

:include sizet.sp

:include null.sp

:include alloca.sp

#define _HEAPOK         0
#define _HEAPEMPTY      1       /* heap isn't initialized */
#define _HEAPBADBEGIN   2       /* heap header is corrupted */
#define _HEAPBADNODE    3       /* heap entry is corrupted */
#define _HEAPEND        4       /* end of heap entries (_heapwalk) */
#define _HEAPBADPTR     5       /* invalid heap entry pointer (_heapwalk) */

#define _USEDENTRY      0
#define _FREEENTRY      1

typedef struct _heapinfo {
    void _WCFAR *_pentry;       /* heap pointer */
    size_t      _size;          /* heap entry size */
    int         _useflag;       /* heap entry 'in-use' flag */
} _HEAPINFO;

_WCRTLINK extern int _heapenable( int __enabled );
_WCRTLINK extern int _heapchk( void );
_WCRTLINK extern int _nheapchk( void );
:segment DOS
_WCRTLINK extern int _fheapchk( void );
:endsegment
_WCRTLINK extern int _heapset( unsigned int __fill );
_WCRTLINK extern int _nheapset( unsigned int __fill );
:segment DOS
_WCRTLINK extern int _fheapset( unsigned int __fill );
:endsegment
_WCRTLINK extern int _heapwalk( struct _heapinfo *__entry );
_WCRTLINK extern int _nheapwalk( struct _heapinfo *__entry );
:segment DOS
_WCRTLINK extern int _fheapwalk( struct _heapinfo *__entry );
:endsegment

_WCRTLINK extern void _heapgrow( void );
_WCRTLINK extern void _nheapgrow( void );
:segment DOS
_WCRTLINK extern void _fheapgrow( void );
:endsegment
_WCRTLINK extern int _heapmin( void );
_WCRTLINK extern int _nheapmin( void );
:segment DOS
_WCRTLINK extern int _fheapmin( void );
:endsegment
_WCRTLINK extern int _heapshrink( void );
_WCRTLINK extern int _nheapshrink( void );
:segment DOS
_WCRTLINK extern int _fheapshrink( void );
:endsegment

_WCRTLINK extern int __nmemneed( size_t );
:segment DOS
_WCRTLINK extern int __fmemneed( size_t );
:endsegment
:segment DOS
#if !defined(_fcalloc) || !defined(_INC_WINDOWSX)
_WCRTLINK extern void _WCFAR *_fcalloc( size_t __n, size_t __size );
#endif
:endsegment
#if !defined(_ncalloc) || !defined(_INC_WINDOWSX)
_WCRTLINK extern void _WCNEAR *_ncalloc( size_t __n, size_t __size );
#endif
_WCRTLINK extern void *_expand( void *__ptr, size_t __size );
:segment DOS
#if !defined(_fexpand) || !defined(_INC_WINDOWSX)
_WCRTLINK extern void _WCFAR *_fexpand( void _WCFAR *__ptr, size_t __size );
#endif
:endsegment
#if !defined(_nexpand) || !defined(_INC_WINDOWSX)
_WCRTLINK extern void _WCNEAR *_nexpand( void _WCNEAR *__ptr, size_t __size );
#endif
:segment DOS
#if !defined(_ffree) || !defined(_INC_WINDOWSX)
_WCRTLINK extern void _ffree( void _WCFAR *__ptr );
#endif
#if !defined(_fmalloc) || !defined(_INC_WINDOWSX)
_WCRTLINK extern void _WCFAR *_fmalloc( size_t __size );
#endif
:endsegment
_WCRTLINK extern unsigned int _freect( size_t __size );
:segment DOS
_WCRTLINK extern void _WCHUGE *halloc( long __n, size_t __size );
_WCRTLINK extern void hfree( void _WCHUGE * );
:endsegment
#if !defined(_nfree) || !defined(_INC_WINDOWSX)
_WCRTLINK extern void _nfree( void _WCNEAR *__ptr );
#endif
#if !defined(_nmalloc) || !defined(_INC_WINDOWSX)
_WCRTLINK extern void _WCNEAR *_nmalloc( size_t __size );
#endif
#if !defined(_nrealloc) || !defined(_INC_WINDOWSX)
_WCRTLINK extern void _WCNEAR *_nrealloc( void _WCNEAR *__ptr, size_t __size );
#endif
:segment DOS
#if !defined(_frealloc) || !defined(_INC_WINDOWSX)
_WCRTLINK extern void _WCFAR *_frealloc( void _WCFAR *__ptr, size_t __size );
#endif
:endsegment
_WCRTLINK extern size_t _msize( void *__ptr );
#if !defined(_nmsize) || !defined(_INC_WINDOWSX)
_WCRTLINK extern size_t _nmsize( void _WCNEAR *__ptr );
#endif
:segment DOS
#if !defined(_fmsize) || !defined(_INC_WINDOWSX)
_WCRTLINK extern size_t _fmsize( void _WCFAR *__ptr );
#endif
:endsegment

_WCRTLINK extern size_t _memavl( void );
_WCRTLINK extern size_t _memmax( void );
#ifdef __cplusplus
namespace std {
#endif
_WCRTLINK extern void *calloc( size_t __n, size_t __size );
_WCRTLINK extern void free( void *__ptr );
_WCRTLINK extern void *malloc( size_t __size );
_WCRTLINK extern void *realloc( void *__ptr, size_t __size );
#ifdef __cplusplus
}
using std::calloc;
using std::free;
using std::malloc;
using std::realloc;
#endif

:segment DOS
#if defined(_M_IX86)
/* based heap function prototypes */

#define _NULLSEG ((__segment)0)
#define _NULLOFF ((void __based(void) *)~0)

_WCRTLINK extern int _bfreeseg( __segment __seg );
_WCRTLINK extern __segment _bheapseg( size_t size );
_WCRTLINK extern void __based(void) *_bcalloc( __segment __seg, size_t __num, size_t __size );
_WCRTLINK extern void __based(void) *_bexpand( __segment __seg, void __based(void) *__mem, size_t __size );
_WCRTLINK extern void _bfree( __segment __seg, void __based(void) *__mem );
_WCRTLINK extern int _bheapchk( __segment __seg );
_WCRTLINK extern int _bheapmin( __segment __seg );
_WCRTLINK extern int _bheapshrink( __segment __seg );
_WCRTLINK extern int _bheapset( __segment __seg, unsigned int __fill );
_WCRTLINK extern int _bheapwalk( __segment __seg, struct _heapinfo *__entry );
_WCRTLINK extern void __based(void) *_bmalloc( __segment __seg, size_t __size );
_WCRTLINK extern size_t _bmsize( __segment __seg, void __based(void) *__mem );
_WCRTLINK extern void __based(void) *_brealloc( __segment __seg, void __based(void) *__mem, size_t __size );
#endif

:endsegment
:include poppack.sp
:include cplusepi.sp
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?