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
13#ifndef ARRAYSIZE
14#define ARRAYSIZE(array) (sizeof(array)/sizeof(array[0]))
15#endif
16
20#ifndef FREE
21#define FREE(ptr) {free(ptr); ptr = NULL;}
22#endif
23
32void *malloc_chk(size_t size, const char *tag);
33
43void *calloc_chk(size_t nmemb, size_t size, const char *tag);
44
53char *strdup_chk(const char *s, const char *tag);
54
64char *strndup_chk(const char *s, size_t len, const char *tag);
65
71void strip_end(char *s);
72
78void strip_casl2_comment(char *s);
79
87char *strrev(const char *s);
88
89#endif
void strip_end(char *s)
文字列の末尾から、改行と空白とタブを削除する
Definition cmem.c:48
char * strndup_chk(const char *s, size_t len, const char *tag)
malloc_chkを実行してメモリを確保し、コピーした文字列の指定した長さの部分を返す
Definition cmem.c:33
void * calloc_chk(size_t nmemb, size_t size, const char *tag)
領域の数とサイズを指定してメモリーを確保するcallocを実行する
Definition cmem.c:14
void strip_casl2_comment(char *s)
文字列から「'」以降の文字列をCASL IIのコメントとして削除する。「''」の場合は除く
Definition cmem.c:55
char * strrev(const char *s)
逆にした文字列を返す
Definition cmem.c:71
void * malloc_chk(size_t size, const char *tag)
mallocを実行し、0で初期化する
Definition cmem.c:3
char * strdup_chk(const char *s, const char *tag)
malloc_chkを実行してメモリを確保し、コピーした文字列を返す
Definition cmem.c:25