root/doc_inner/gnu_global/S/2831.html

/* [<][>][^][v][top][bottom][index][help] */
<!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>src/cmem.c</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/2932.html'>src</a>/cmem.c</h2>
<em class='comment'>/* [&lt;][&gt;]<a href='#L3'>[^]</a><a href='#L71'>[v]</a>[top]<a href='#BOTTOM'>[bottom]</a><a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</em>
<hr />
<h2 class='header'>DEFINITIONS</h2>
This source file includes following definitions.
<ol>
<li><a href='#L3' title='Defined at 3.'>malloc_chk</a></li>
<li><a href='#L14' title='Defined at 14.'>calloc_chk</a></li>
<li><a href='#L25' title='Defined at 25.'>strdup_chk</a></li>
<li><a href='#L33' title='Defined at 33.'>strndup_chk</a></li>
<li><a href='#L48' title='Defined at 48.'>strip_end</a></li>
<li><a href='#L55' title='Defined at 55.'>strip_casl2_comment</a></li>
<li><a href='#L71' title='Defined at 71.'>strrev</a></li>
</ol>
<hr />
<pre>
<a id='L1' name='L1'></a>   1 <em class='sharp'>#include</em> "<a href='2424.html'>cmem.h</a>"
<a id='L2' name='L2'></a>   2 
<a id='L3' name='L3'></a>   3 <strong class='reserved'>void</strong> *<a href='../R/181.html' title='Multiple referred from 39 places.'>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='L4' name='L4'></a>   4 <em class='brace'>{</em>
<a id='L5' name='L5'></a>   5     <strong class='reserved'>void</strong> *<a href='../Y/171.html' title='Multiple used in 127 places.'>p</a> = <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>;
<a id='L6' name='L6'></a>   6 
<a id='L7' name='L7'></a>   7     <strong class='reserved'>if</strong>((<a href='../Y/171.html' title='Multiple used in 127 places.'>p</a> = <a href='../Y/142.html' title='Multiple used in 7 places.'>malloc</a>(<a href='../Y/191.html' title='Multiple used in 7 places.'>size</a>)) == <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>) <em class='brace'>{</em>
<a id='L8' name='L8'></a>   8         <a href='../Y/102.html' title='Multiple used in 115 places.'>fprintf</a>(<a href='../Y/198.html' title='Multiple used in 23 places.'>stderr</a>, "%s: cannot allocate memory\n", <a href='../Y/220.html' title='Multiple used in 13 places.'>tag</a>);
<a id='L9' name='L9'></a>   9         <a href='../Y/90.html' title='Multiple used in 8 places.'>exit</a>(1);
<a id='L10' name='L10'></a>  10     <em class='brace'>}</em>
<a id='L11' name='L11'></a>  11     <strong class='reserved'>return</strong> memset(<a href='../Y/171.html' title='Multiple used in 127 places.'>p</a>, 0, <a href='../Y/191.html' title='Multiple used in 7 places.'>size</a>);
<a id='L12' name='L12'></a>  12 <em class='brace'>}</em>
<a id='L13' name='L13'></a>  13 
<a id='L14' name='L14'></a>  14 <strong class='reserved'>void</strong> *<a href='../R/115.html' title='Multiple referred from 4 places.'>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='L15' name='L15'></a>  15 <em class='brace'>{</em>
<a id='L16' name='L16'></a>  16     <strong class='reserved'>void</strong> *<a href='../Y/171.html' title='Multiple used in 127 places.'>p</a> = <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>;
<a id='L17' name='L17'></a>  17 
<a id='L18' name='L18'></a>  18     <strong class='reserved'>if</strong>((<a href='../Y/171.html' title='Multiple used in 127 places.'>p</a> = calloc(<a href='../Y/155.html' title='Multiple used in 3 places.'>nmemb</a>, <a href='../Y/191.html' title='Multiple used in 7 places.'>size</a>)) == <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>) <em class='brace'>{</em>
<a id='L19' name='L19'></a>  19         <a href='../Y/102.html' title='Multiple used in 115 places.'>fprintf</a>(<a href='../Y/198.html' title='Multiple used in 23 places.'>stderr</a>, "%s: cannot allocate memory\n", <a href='../Y/220.html' title='Multiple used in 13 places.'>tag</a>);
<a id='L20' name='L20'></a>  20         <a href='../Y/90.html' title='Multiple used in 8 places.'>exit</a>(1);
<a id='L21' name='L21'></a>  21     <em class='brace'>}</em>
<a id='L22' name='L22'></a>  22     <strong class='reserved'>return</strong> <a href='../Y/171.html' title='Multiple used in 127 places.'>p</a>;
<a id='L23' name='L23'></a>  23 <em class='brace'>}</em>
<a id='L24' name='L24'></a>  24 
<a id='L25' name='L25'></a>  25 <strong class='reserved'>char</strong> *<a href='../R/215.html' title='Multiple referred from 14 places.'>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='L26' name='L26'></a>  26 <em class='brace'>{</em>
<a id='L27' name='L27'></a>  27     <a href='../Y/20.html' title='Multiple used in 22 places.'>assert</a>(<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a> != <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>);
<a id='L28' name='L28'></a>  28     <strong class='reserved'>char</strong> *<a href='../Y/218.html' title='Multiple used in 30 places.'>t</a> = <a href='../S/2831.html#L3' title='Defined at 3 in src/cmem.c.'>malloc_chk</a>(<a href='../Y/212.html' title='Multiple used in 7 places.'>strlen</a>(<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>) + 1, <a href='../Y/220.html' title='Multiple used in 13 places.'>tag</a>);
<a id='L29' name='L29'></a>  29     <a href='../Y/208.html' title='Multiple used in 4 places.'>strcpy</a>(<a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>, <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>);
<a id='L30' name='L30'></a>  30     <strong class='reserved'>return</strong> <a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>;
<a id='L31' name='L31'></a>  31 <em class='brace'>}</em>
<a id='L32' name='L32'></a>  32 
<a id='L33' name='L33'></a>  33 <strong class='reserved'>char</strong> *<a href='../R/218.html' title='Multiple referred from 7 places.'>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='L34' name='L34'></a>  34 <em class='brace'>{</em>
<a id='L35' name='L35'></a>  35     <a href='../Y/20.html' title='Multiple used in 22 places.'>assert</a>(<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a> != <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>);
<a id='L36' name='L36'></a>  36     <strong class='reserved'>char</strong> *<a href='../Y/218.html' title='Multiple used in 30 places.'>t</a> = <a href='../Y/3.html' title='Multiple used in 191 places.'>NULL</a>;
<a id='L37' name='L37'></a>  37 
<a id='L38' name='L38'></a>  38     <strong class='reserved'>if</strong>(<a href='../Y/131.html' title='Multiple used in 8 places.'>len</a> &lt; <a href='../Y/212.html' title='Multiple used in 7 places.'>strlen</a>(<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>)) <em class='brace'>{</em>
<a id='L39' name='L39'></a>  39         <a href='../Y/218.html' title='Multiple used in 30 places.'>t</a> = <a href='../S/2831.html#L3' title='Defined at 3 in src/cmem.c.'>malloc_chk</a>(<a href='../Y/131.html' title='Multiple used in 8 places.'>len</a> + 1, <a href='../Y/220.html' title='Multiple used in 13 places.'>tag</a>);
<a id='L40' name='L40'></a>  40         strncpy(<a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>, <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>, <a href='../Y/131.html' title='Multiple used in 8 places.'>len</a>);
<a id='L41' name='L41'></a>  41         <a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>[<a href='../Y/131.html' title='Multiple used in 8 places.'>len</a>] = '\0';
<a id='L42' name='L42'></a>  42     <em class='brace'>}</em> <strong class='reserved'>else</strong> <em class='brace'>{</em>
<a id='L43' name='L43'></a>  43         <a href='../Y/218.html' title='Multiple used in 30 places.'>t</a> = <a href='../S/2831.html#L25' title='Defined at 25 in src/cmem.c.'>strdup_chk</a>(<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>, <a href='../Y/220.html' title='Multiple used in 13 places.'>tag</a>);
<a id='L44' name='L44'></a>  44     <em class='brace'>}</em>
<a id='L45' name='L45'></a>  45     <strong class='reserved'>return</strong> <a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>;
<a id='L46' name='L46'></a>  46 <em class='brace'>}</em>
<a id='L47' name='L47'></a>  47 
<a id='L48' name='L48'></a>  48 <strong class='reserved'>void</strong> <a href='../R/217.html' title='Multiple referred from 5 places.'>strip_end</a>(<strong class='reserved'>char</strong> *<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>)
<a id='L49' name='L49'></a>  49 <em class='brace'>{</em>
<a id='L50' name='L50'></a>  50     <strong class='reserved'>for</strong>(<strong class='reserved'>int</strong> <a href='../Y/117.html' title='Multiple used in 233 places.'>i</a> = <a href='../Y/212.html' title='Multiple used in 7 places.'>strlen</a>(<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>) - 1; <a href='../Y/117.html' title='Multiple used in 233 places.'>i</a> &gt; 0 &amp;&amp; (<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>] == '\n' || <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>] == '\r' || <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>] == ' ' || <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>] == '\t'); <a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>--) <em class='brace'>{</em>
<a id='L51' name='L51'></a>  51         <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>] = '\0';
<a id='L52' name='L52'></a>  52     <em class='brace'>}</em>
<a id='L53' name='L53'></a>  53 <em class='brace'>}</em>
<a id='L54' name='L54'></a>  54 
<a id='L55' name='L55'></a>  55 <strong class='reserved'>void</strong> <a href='../R/216.html' title='Multiple referred from 4 places.'>strip_casl2_comment</a>(<strong class='reserved'>char</strong> *<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>)
<a id='L56' name='L56'></a>  56 <em class='brace'>{</em>
<a id='L57' name='L57'></a>  57     <a href='../Y/25.html' title='Multiple used in 55 places.'>bool</a> <a href='../Y/183.html' title='Multiple used in 8 places.'>quoting</a> = <a href='../Y/92.html' title='Multiple used in 52 places.'>false</a>;
<a id='L58' name='L58'></a>  58 
<a id='L59' name='L59'></a>  59     <strong class='reserved'>for</strong>(<strong class='reserved'>int</strong> <a href='../Y/117.html' title='Multiple used in 233 places.'>i</a> = 0; <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>]; <a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>++) <em class='brace'>{</em>
<a id='L60' name='L60'></a>  60         <em class='comment'>/* 「'」で囲まれた文字列の場合。「''」は無視 */</em>
<a id='L61' name='L61'></a>  61         <strong class='reserved'>if</strong>(<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>] == '\'' &amp;&amp; <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>+1] != '\'' &amp;&amp; (<a href='../Y/183.html' title='Multiple used in 8 places.'>quoting</a> == <a href='../Y/92.html' title='Multiple used in 52 places.'>false</a> || <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>-1] != '\'')) <em class='brace'>{</em>
<a id='L62' name='L62'></a>  62             <a href='../Y/183.html' title='Multiple used in 8 places.'>quoting</a> = !<a href='../Y/183.html' title='Multiple used in 8 places.'>quoting</a>;
<a id='L63' name='L63'></a>  63         <em class='comment'>/* 「'」で囲まれた文字列でない場合、文字列末尾の「;」以降を削除 */</em>
<a id='L64' name='L64'></a>  64         <em class='brace'>}</em> <strong class='reserved'>else</strong> <strong class='reserved'>if</strong>(<a href='../Y/183.html' title='Multiple used in 8 places.'>quoting</a> == <a href='../Y/92.html' title='Multiple used in 52 places.'>false</a> &amp;&amp; <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>] == ';') <em class='brace'>{</em>
<a id='L65' name='L65'></a>  65             <a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>] = '\0';
<a id='L66' name='L66'></a>  66             <strong class='reserved'>break</strong>;
<a id='L67' name='L67'></a>  67         <em class='brace'>}</em>
<a id='L68' name='L68'></a>  68     <em class='brace'>}</em>
<a id='L69' name='L69'></a>  69 <em class='brace'>}</em>
<a id='L70' name='L70'></a>  70 
<a id='L71' name='L71'></a>  71 <strong class='reserved'>char</strong> *<a href='../R/219.html' title='Multiple referred from 3 places.'>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='L72' name='L72'></a>  72 <em class='brace'>{</em>
<a id='L73' name='L73'></a>  73     <strong class='reserved'>char</strong> *<a href='../Y/218.html' title='Multiple used in 30 places.'>t</a> = <a href='../S/2831.html#L25' title='Defined at 25 in src/cmem.c.'>strdup_chk</a>(<a href='../Y/188.html' title='Multiple used in 74 places.'>s</a>, "strrev.t");
<a id='L74' name='L74'></a>  74     <strong class='reserved'>int</strong> <a href='../Y/126.html' title='Multiple used in 22 places.'>l</a> = <a href='../Y/212.html' title='Multiple used in 7 places.'>strlen</a>(<a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>);
<a id='L75' name='L75'></a>  75 
<a id='L76' name='L76'></a>  76     <strong class='reserved'>for</strong>(<strong class='reserved'>int</strong> <a href='../Y/117.html' title='Multiple used in 233 places.'>i</a> = 0; <a href='../Y/117.html' title='Multiple used in 233 places.'>i</a> &lt; <a href='../Y/126.html' title='Multiple used in 22 places.'>l</a>-1-<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>; <a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>++) <em class='brace'>{</em>
<a id='L77' name='L77'></a>  77         <strong class='reserved'>char</strong> <a href='../Y/224.html' title='Multiple used in 5 places.'>tmp</a> = <a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>];
<a id='L78' name='L78'></a>  78         <a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>[<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>] = <a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>[<a href='../Y/126.html' title='Multiple used in 22 places.'>l</a>-1-<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>];
<a id='L79' name='L79'></a>  79         <a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>[<a href='../Y/126.html' title='Multiple used in 22 places.'>l</a>-1-<a href='../Y/117.html' title='Multiple used in 233 places.'>i</a>] = <a href='../Y/224.html' title='Multiple used in 5 places.'>tmp</a>;
<a id='L80' name='L80'></a>  80     <em class='brace'>}</em>
<a id='L81' name='L81'></a>  81     <strong class='reserved'>return</strong> <a href='../Y/218.html' title='Multiple used in 30 places.'>t</a>;
<a id='L82' name='L82'></a>  82 <em class='brace'>}</em>
</pre>
<hr />
<a id='BOTTOM' name='BOTTOM'></a>
<em class='comment'>/* [&lt;][&gt;]<a href='#L3'>[^]</a><a href='#L71'>[v]</a><a href='#TOP'>[top]</a>[bottom]<a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</em>
</body>
</html>

/* [<][>][^][v][top][bottom][index][help] */