Merge branch 'master' of dragon:/home/dav/yacasl2
[YACASL2.git] / include / cmem.h
1 #ifndef YACASL2_CMEM_H_INCLUDED
2 #define YACASL2_CMEM_H_INCLUDED
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <assert.h>
8 #include <stdbool.h>
9
10 #ifndef ARRAYSIZE
11 #define ARRAYSIZE(array) (sizeof(array)/sizeof(array[0]))
12 #endif
13
14 /* mallocを実行し、0で初期化 */
15 /* メモリを確保できない場合はエラーを出力して終了 */
16 void *malloc_chk(size_t size, char *tag);
17
18 /* callocを実行 */
19 /* メモリを確保できない場合はエラーを出力して終了 */
20 void *calloc_chk(size_t nmemb, size_t size, char *tag);
21
22 /* malloc_chkを実行してメモリを確保してから、 */
23 /* コピーした文字列を返す */
24 char *strdup_chk(const char *s, char *tag);
25
26 /* メモリがNULLの場合は解放 */
27 void free_chk(void *ptr, char *tag);
28 #endif