mallocをラップするマクロ

検索するといろいろ出てくる。何をどう使ったらいいかね〜、解からん〜

とりあえずmyisamに倣って、my_mallocとmy_freeをつかっておこうかな。

#define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG )
#define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG )
#define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG )
#define my_checkmalloc() _sanity( __FILE__, __LINE__ )
#define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG)

ここで、my系関数に渡すFLAGというのがあるけれども、こいつは、

        /* General bitmaps for my_func's */
#define MY_FFNF         1       /* Fatal if file not found */
#define MY_FNABP        2       /* Fatal if not all bytes read/writen */
#define MY_NABP         4       /* Error if not all bytes read/writen */
#define MY_FAE          8       /* Fatal if any error */
#define MY_WME          16      /* Write message on error */
#define MY_WAIT_IF_FULL 32      /* Wait and try again if disk full error */
#define MY_IGNORE_BADFD 32      /* my_sync: ignore 'bad descriptor' errors */
#define MY_RAID         64      /* Support for RAID */
#define MY_FULL_IO     512      /* For my_read - loop intil I/O is complete */
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
#define MY_LINK_WARNING 32      /* my_redel() gives warning if links */
#define MY_COPYTIME     64      /* my_redel() copys time */
#define MY_DELETE_OLD   256     /* my_create_with_symlink() */
#define MY_RESOLVE_LINK 128     /* my_realpath(); Only resolve links */
#define MY_HOLD_ORIGINAL_MODES 128  /* my_copy() holds to file modes */
#define MY_REDEL_MAKE_BACKUP 256
#define MY_SEEK_NOT_DONE 32     /* my_lock may have to do a seek */
#define MY_DONT_WAIT    64      /* my_lock() don't wait if can't lock */
#define MY_ZEROFILL     32      /* my_malloc(), fill array with zero */
#define MY_ALLOW_ZERO_PTR 64    /* my_realloc() ; zero ptr -> malloc */
#define MY_FREE_ON_ERROR 128    /* my_realloc() ; Free old ptr on error */
#define MY_HOLD_ON_ERROR 256    /* my_realloc() ; Return old ptr on error */
#define MY_THREADSAFE   128     /* pread/pwrite:  Don't allow interrupts */
#define MY_DONT_OVERWRITE_FILE 1024     /* my_copy: Don't overwrite file */

こんな感じで定義されてる。mallocシステムコールでエラーが返った時、エラーログを出したいならMY_WME、プロセスを終了したいならMY_FAEみたいな感じでせうか。

どちらもinclude/my_sys.hより。