YACASL2
Loading...
Searching...
No Matches
cmem.h
Go to the documentation of this file.
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#include <limits.h>
10
14#ifndef ARRAYSIZE
15#define ARRAYSIZE(array) (sizeof(array)/sizeof(array[0]))
16#endif
17
21#ifndef FREE
22#define FREE(ptr) do { free(ptr); (ptr) = NULL; } while(0)
23#endif
24
34long str2l_range(const char *str, long min, long max, const char *name);
35
44void *malloc_chk(size_t size, const char *tag);
45
55void *calloc_chk(size_t nmemb, size_t size, const char *tag);
56
65char *strdup_chk(const char *s, const char *tag);
66
76char *strndup_chk(const char *s, size_t len, const char *tag);
77
83void strip_end(char *s);
84
90void strip_casl2_comment(char *s);
91
99char *strrev(const char *s);
100
101#endif
void strip_end(char *s)
文字列の末尾から、改行と空白とタブを削除する
Definition cmem.c:68
char * strndup_chk(const char *s, size_t len, const char *tag)
malloc_chkを実行してメモリを確保し、コピーした文字列の指定した長さの部分を返す
Definition cmem.c:53
void * calloc_chk(size_t nmemb, size_t size, const char *tag)
領域の数とサイズを指定してメモリーを確保するcallocを実行する
Definition cmem.c:34
void strip_casl2_comment(char *s)
文字列から「'」以降の文字列をCASL IIのコメントとして削除する。「''」の場合は除く
Definition cmem.c:75
char * strrev(const char *s)
逆にした文字列を返す
Definition cmem.c:91
void * malloc_chk(size_t size, const char *tag)
mallocを実行し、0で初期化する
Definition cmem.c:23
long str2l_range(const char *str, long min, long max, const char *name)
数値文字列が特定の範囲の数値かチェックし、正の場合は変換した数値、不正の場合は0を返す
Definition cmem.c:3
char * strdup_chk(const char *s, const char *tag)
malloc_chkを実行してメモリを確保し、コピーした文字列を返す
Definition cmem.c:45