-/* mallocを実行し、メモリを確保できない場合は */
-/* エラーを出力して終了 */
-void *malloc_chk(size_t size, char *tag)
-{
- void *p;
-
- if((p = malloc(size)) == NULL) {
- fprintf(stderr, "%s: cannot allocate memory\n", tag);
- exit(-1);
- }
- return p;
-}
-
-/* callocを実行し、メモリを確保できない場合は */
-/* エラーを出力して終了 */
-void *calloc_chk(size_t nmemb, size_t size, char *tag)
-{
- void *p;
-
- if((p = calloc(nmemb, size)) == NULL) {
- fprintf(stderr, "%s: cannot allocate memory\n", tag);
- exit(-1);
- }
- return p;
-}
-
-/* エラーの初期化 */