<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>include/cmem.h</title> <meta name='robots' content='noindex,nofollow' /> <meta name='generator' content='GLOBAL-6.6.5' /> <meta http-equiv='Content-Style-Type' content='text/css' /> <link rel='stylesheet' type='text/css' href='../style.css' /> </head> <body> <a id='TOP' name='TOP'></a><h2 class='header'><a href='../mains.html'>root</a>/<a href='../files/2930.html'>include</a>/cmem.h</h2> <em class='comment'>/* [<][>][^][v][top]<a href='#BOTTOM'>[bottom]</a><a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</em> <hr /> <h2 class='header'><a href='../J/1308.html' title='Multiple included from 15 places.'>INCLUDED FROM</a></h2> <hr /> <pre> <a id='L1' name='L1'></a> 1 <em class='sharp'>#ifndef</em> <a href='../S/2424.html#L2' title='Defined at 2 in include/cmem.h.'>YACASL2_CMEM_H_INCLUDED</a> <a id='L2' name='L2'></a> 2 <em class='sharp'>#define</em> <a href='../S/2424.html#L1' title='Referred from 1 in include/cmem.h.'>YACASL2_CMEM_H_INCLUDED</a> <a id='L3' name='L3'></a> 3 <a id='L4' name='L4'></a> 4 <em class='sharp'>#include</em> <stdio.h> <a id='L5' name='L5'></a> 5 <em class='sharp'>#include</em> <stdlib.h> <a id='L6' name='L6'></a> 6 <em class='sharp'>#include</em> <string.h> <a id='L7' name='L7'></a> 7 <em class='sharp'>#include</em> <assert.h> <a id='L8' name='L8'></a> 8 <em class='sharp'>#include</em> <stdbool.h> <a id='L9' name='L9'></a> 9 <a id='L10' name='L10'></a> 10 <em class='comment'>/**</em> <a id='L11' name='L11'></a> 11 <em class='comment'> * @brief 配列のサイズを返すマクロ</em> <a id='L12' name='L12'></a> 12 <em class='comment'> */</em> <a id='L13' name='L13'></a> 13 <em class='sharp'>#ifndef</em> <a href='../S/2424.html#L14' title='Defined at 14 in include/cmem.h.'>ARRAYSIZE</a> <a id='L14' name='L14'></a> 14 <em class='sharp'>#define</em> <a href='../R/2.html' title='Multiple referred from 28 places.'>ARRAYSIZE</a>(array) (<strong class='reserved'>sizeof</strong>(array)/<strong class='reserved'>sizeof</strong>(array[0])) <a id='L15' name='L15'></a> 15 <em class='sharp'>#endif</em> <a id='L16' name='L16'></a> 16 <a id='L17' name='L17'></a> 17 <em class='comment'>/**</em> <a id='L18' name='L18'></a> 18 <em class='comment'> * @brief メモリを解放するマクロ</em> <a id='L19' name='L19'></a> 19 <em class='comment'> */</em> <a id='L20' name='L20'></a> 20 <em class='sharp'>#ifndef</em> <a href='../S/2424.html#L21' title='Defined at 21 in include/cmem.h.'>FREE</a> <a id='L21' name='L21'></a> 21 <em class='sharp'>#define</em> <a href='../R/25.html' title='Multiple referred from 71 places.'>FREE</a>(<a href='../Y/178.html' title='Multiple used in 24 places.'>ptr</a>) <em class='brace'>{</em>free(<a href='../Y/178.html' title='Multiple used in 24 places.'>ptr</a>); <a href='../Y/178.html' title='Multiple used in 24 places.'>ptr</a> = <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>;<em class='brace'>}</em> <a id='L22' name='L22'></a> 22 <em class='sharp'>#endif</em> <a id='L23' name='L23'></a> 23 <a id='L24' name='L24'></a> 24 <em class='comment'>/**</em> <a id='L25' name='L25'></a> 25 <em class='comment'> * @brief mallocを実行し、0で初期化する</em> <a id='L26' name='L26'></a> 26 <em class='comment'> *</em> <a id='L27' name='L27'></a> 27 <em class='comment'> * メモリを確保できない場合はエラーを出力して終了</em> <a id='L28' name='L28'></a> 28 <em class='comment'> *</em> <a id='L29' name='L29'></a> 29 <em class='comment'> * @return なし</em> <a id='L30' name='L30'></a> 30 <em class='comment'> *</em> <a id='L31' name='L31'></a> 31 <em class='comment'> * @param size メモリーのサイズ</em> <a id='L32' name='L32'></a> 32 <em class='comment'> * @param tag エラーメッセージなどで表示されるタグ</em> <a id='L33' name='L33'></a> 33 <em class='comment'> */</em> <a id='L34' name='L34'></a> 34 <strong class='reserved'>void</strong> *<a href='../S/2831.html#L3' title='Defined at 3 in src/cmem.c.'>malloc_chk</a>(<a href='../Y/192.html' title='Multiple used in 9 places.'>size_t</a> <a href='../Y/191.html' title='Multiple used in 7 places.'>size</a>, <strong class='reserved'>const</strong> <strong class='reserved'>char</strong> *<a href='../Y/220.html' title='Multiple used in 13 places.'>tag</a>); <a id='L35' name='L35'></a> 35 <a id='L36' name='L36'></a> 36 <em class='comment'>/**</em> <a id='L37' name='L37'></a> 37 <em class='comment'> * @brief 領域の数とサイズを指定してメモリーを確保するcallocを実行する</em> <a id='L38' name='L38'></a> 38 <em class='comment'> *</em> <a id='L39' name='L39'></a> 39 <em class='comment'> * メモリを確保できない場合はエラーを出力して終了</em> <a id='L40' name='L40'></a> 40 <em class='comment'> *</em> <a id='L41' name='L41'></a> 41 <em class='comment'> * @return なし</em> <a id='L42' name='L42'></a> 42 <em class='comment'> *</em> <a id='L43' name='L43'></a> 43 <em class='comment'> * @param nmemb 領域の数</em> <a id='L44' name='L44'></a> 44 <em class='comment'> * @param size 領域1個あたりのメモリーサイズ</em> <a id='L45' name='L45'></a> 45 <em class='comment'> * @param tag エラーメッセージなどで表示されるタグ</em> <a id='L46' name='L46'></a> 46 <em class='comment'> */</em> <a id='L47' name='L47'></a> 47 <strong class='reserved'>void</strong> *<a href='../S/2831.html#L14' title='Defined at 14 in src/cmem.c.'>calloc_chk</a>(<a href='../Y/192.html' title='Multiple used in 9 places.'>size_t</a> <a href='../Y/155.html' title='Multiple used in 3 places.'>nmemb</a>, <a href='../Y/192.html' title='Multiple used in 9 places.'>size_t</a> <a href='../Y/191.html' title='Multiple used in 7 places.'>size</a>, <strong class='reserved'>const</strong> <strong class='reserved'>char</strong> *<a href='../Y/220.html' title='Multiple used in 13 places.'>tag</a>); <a id='L48' name='L48'></a> 48 <a id='L49' name='L49'></a> 49 <em class='comment'>/**</em> <a id='L50' name='L50'></a> 50 <em class='comment'> * @brief malloc_chkを実行してメモリを確保し、コピーした文字列を返す</em> <a id='L51' name='L51'></a> 51 <em class='comment'> *</em> <a id='L52' name='L52'></a> 52 <em class='comment'> * @return コピーした文字列</em> <a id='L53' name='L53'></a> 53 <em class='comment'> *</em> <a id='L54' name='L54'></a> 54 <em class='comment'> * @param s 文字列</em> <a id='L55' name='L55'></a> 55 <em class='comment'> * @param tag エラーメッセージなどで表示されるタグ</em> <a id='L56' name='L56'></a> 56 <em class='comment'> */</em> <a id='L57' name='L57'></a> 57 <strong class='reserved'>char</strong> *<a href='../S/2831.html#L25' title='Defined at 25 in src/cmem.c.'>strdup_chk</a>(<strong class='reserved'>const</strong> <strong class='reserved'>char</strong> *<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>, <strong class='reserved'>const</strong> <strong class='reserved'>char</strong> *<a href='../Y/220.html' title='Multiple used in 13 places.'>tag</a>); <a id='L58' name='L58'></a> 58 <a id='L59' name='L59'></a> 59 <em class='comment'>/**</em> <a id='L60' name='L60'></a> 60 <em class='comment'> * @brief malloc_chkを実行してメモリを確保し、コピーした文字列の指定した長さの部分を返す</em> <a id='L61' name='L61'></a> 61 <em class='comment'> *</em> <a id='L62' name='L62'></a> 62 <em class='comment'> * @return コピーした文字列</em> <a id='L63' name='L63'></a> 63 <em class='comment'> *</em> <a id='L64' name='L64'></a> 64 <em class='comment'> * @param s 文字列</em> <a id='L65' name='L65'></a> 65 <em class='comment'> * @param len 文字列の長さ</em> <a id='L66' name='L66'></a> 66 <em class='comment'> * @param tag エラーメッセージなどで表示されるタグ</em> <a id='L67' name='L67'></a> 67 <em class='comment'> */</em> <a id='L68' name='L68'></a> 68 <strong class='reserved'>char</strong> *<a href='../S/2831.html#L33' title='Defined at 33 in src/cmem.c.'>strndup_chk</a>(<strong class='reserved'>const</strong> <strong class='reserved'>char</strong> *<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>, <a href='../Y/192.html' title='Multiple used in 9 places.'>size_t</a> <a href='../Y/131.html' title='Multiple used in 8 places.'>len</a>, <strong class='reserved'>const</strong> <strong class='reserved'>char</strong> *<a href='../Y/220.html' title='Multiple used in 13 places.'>tag</a>); <a id='L69' name='L69'></a> 69 <a id='L70' name='L70'></a> 70 <em class='comment'>/**</em> <a id='L71' name='L71'></a> 71 <em class='comment'> * @brief 文字列の末尾から、改行と空白とタブを削除する</em> <a id='L72' name='L72'></a> 72 <em class='comment'> *</em> <a id='L73' name='L73'></a> 73 <em class='comment'> * @return なし</em> <a id='L74' name='L74'></a> 74 <em class='comment'> *</em> <a id='L75' name='L75'></a> 75 <em class='comment'> * @param s 文字列</em> <a id='L76' name='L76'></a> 76 <em class='comment'> */</em> <a id='L77' name='L77'></a> 77 <strong class='reserved'>void</strong> <a href='../S/2831.html#L48' title='Defined at 48 in src/cmem.c.'>strip_end</a>(<strong class='reserved'>char</strong> *<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>); <a id='L78' name='L78'></a> 78 <a id='L79' name='L79'></a> 79 <em class='comment'>/**</em> <a id='L80' name='L80'></a> 80 <em class='comment'> * @brief 文字列から「'」以降の文字列をCASL IIのコメントとして削除する。「''」の場合は除く</em> <a id='L81' name='L81'></a> 81 <em class='comment'> *</em> <a id='L82' name='L82'></a> 82 <em class='comment'> * @return なし</em> <a id='L83' name='L83'></a> 83 <em class='comment'> *</em> <a id='L84' name='L84'></a> 84 <em class='comment'> * @param s 文字列</em> <a id='L85' name='L85'></a> 85 <em class='comment'> */</em> <a id='L86' name='L86'></a> 86 <strong class='reserved'>void</strong> <a href='../S/2831.html#L55' title='Defined at 55 in src/cmem.c.'>strip_casl2_comment</a>(<strong class='reserved'>char</strong> *<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>); <a id='L87' name='L87'></a> 87 <a id='L88' name='L88'></a> 88 <em class='comment'>/**</em> <a id='L89' name='L89'></a> 89 <em class='comment'> * @brief 逆にした文字列を返す</em> <a id='L90' name='L90'></a> 90 <em class='comment'> *</em> <a id='L91' name='L91'></a> 91 <em class='comment'> * @return 逆にしたした文字列</em> <a id='L92' name='L92'></a> 92 <em class='comment'> *</em> <a id='L93' name='L93'></a> 93 <em class='comment'> * @param s 文字列</em> <a id='L94' name='L94'></a> 94 <em class='comment'> */</em> <a id='L95' name='L95'></a> 95 <strong class='reserved'>char</strong> *<a href='../S/2831.html#L71' title='Defined at 71 in src/cmem.c.'>strrev</a>(<strong class='reserved'>const</strong> <strong class='reserved'>char</strong> *<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>); <a id='L96' name='L96'></a> 96 <a id='L97' name='L97'></a> 97 <em class='sharp'>#endif</em> </pre> <hr /> <a id='BOTTOM' name='BOTTOM'></a> <em class='comment'>/* [<][>][^][v]<a href='#TOP'>[top]</a>[bottom]<a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</em> </body> </html>