YACASL2
Loading...
Searching...
No Matches
cmem.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdbool.h>
Include dependency graph for cmem.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ARRAYSIZE(array)
 配列のサイズを返すマクロ
#define FREE(ptr)
 メモリを解放するマクロ

Functions

void * malloc_chk (size_t size, const char *tag)
 mallocを実行し、0で初期化する
void * calloc_chk (size_t nmemb, size_t size, const char *tag)
 領域の数とサイズを指定してメモリーを確保するcallocを実行する
char * strdup_chk (const char *s, const char *tag)
 malloc_chkを実行してメモリを確保し、コピーした文字列を返す
char * strndup_chk (const char *s, size_t len, const char *tag)
 malloc_chkを実行してメモリを確保し、コピーした文字列の指定した長さの部分を返す
void strip_end (char *s)
 文字列の末尾から、改行と空白とタブを削除する
void strip_casl2_comment (char *s)
 文字列から「'」以降の文字列をCASL IIのコメントとして削除する。「''」の場合は除く
char * strrev (const char *s)
 逆にした文字列を返す

Macro Definition Documentation

◆ ARRAYSIZE

#define ARRAYSIZE ( array)
Value:
(sizeof(array)/sizeof(array[0]))

配列のサイズを返すマクロ

Definition at line 14 of file cmem.h.

◆ FREE

#define FREE ( ptr)
Value:
{free(ptr); ptr = NULL;}

メモリを解放するマクロ

Definition at line 21 of file cmem.h.

Function Documentation

◆ calloc_chk()

void * calloc_chk ( size_t nmemb,
size_t size,
const char * tag )

領域の数とサイズを指定してメモリーを確保するcallocを実行する

メモリを確保できない場合はエラーを出力して終了

Parameters
nmemb領域の数
size領域1個あたりのメモリーサイズ
tagエラーメッセージなどで表示されるタグ

Definition at line 14 of file cmem.c.

Here is the caller graph for this function:

◆ malloc_chk()

void * malloc_chk ( size_t size,
const char * tag )

mallocを実行し、0で初期化する

メモリを確保できない場合はエラーを出力して終了

Parameters
sizeメモリーのサイズ
tagエラーメッセージなどで表示されるタグ

Definition at line 3 of file cmem.c.

Here is the caller graph for this function:

◆ strdup_chk()

char * strdup_chk ( const char * s,
const char * tag )

malloc_chkを実行してメモリを確保し、コピーした文字列を返す

Returns
コピーした文字列
Parameters
s文字列
tagエラーメッセージなどで表示されるタグ

Definition at line 25 of file cmem.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strip_casl2_comment()

void strip_casl2_comment ( char * s)

文字列から「'」以降の文字列をCASL IIのコメントとして削除する。「''」の場合は除く

Parameters
s文字列

Definition at line 55 of file cmem.c.

Here is the caller graph for this function:

◆ strip_end()

void strip_end ( char * s)

文字列の末尾から、改行と空白とタブを削除する

Parameters
s文字列

Definition at line 48 of file cmem.c.

Here is the caller graph for this function:

◆ strndup_chk()

char * strndup_chk ( const char * s,
size_t len,
const char * tag )

malloc_chkを実行してメモリを確保し、コピーした文字列の指定した長さの部分を返す

Returns
コピーした文字列
Parameters
s文字列
len文字列の長さ
tagエラーメッセージなどで表示されるタグ

Definition at line 33 of file cmem.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strrev()

char * strrev ( const char * s)

逆にした文字列を返す

Returns
逆にしたした文字列
Parameters
s文字列

Definition at line 71 of file cmem.c.

Here is the call graph for this function:
Here is the caller graph for this function: