2014年10月29日水曜日

開発環境

Head First C ―頭とからだで覚えるCの基本(David Griffiths (著)、Dawn Griffiths (著) 中田 秀基(監訳)(翻訳)、木下 哲也 (翻訳)、オライリージャパン)の6章(データ構造と動的メモリ: 架け橋を築く)、大きな疑問(p.305)を解いてみる。

その他参考書籍

大きな疑問(p.305)

  1. 19bytes
  2. ロレッタ・バーンスワース
  3. current->question = strdup(question);
    
  4. free(current->question);
    current->question = strdup(question);
    

確認。(ValgrindがYosemiteにまだ対応してないみたいだから、VMware fusion上のUbuntuで確認。)

Makefile

P=
CC=cc
CFLAGS=-g -Wall # -O3
SRC=
OBJ=
LDLIBS=

$(P): $(OBJ)
 $(CC) $(CFLAGS) $(LDLIBS) $(OBJ) -o $@

入出力結果(Terminal)

$ make spies
cc -g -Wall     spies.c   -o spies
$ valgrind --leak-check=full ./spies
==5285== Memcheck, a memory error detector
==5285== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==5285== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==5285== Command: ./spies
==5285== 
容疑者はひげを生やしているか? (y/n): n
123456789012345678? (y/n): n
容疑者は誰? 12
12には当てはまり、123456789012345678には当てはまらない質問は?  1234567890
再実行しますか ? (y/n): n
==5285== 
==5285== HEAP SUMMARY:
==5285==     in use at exit: 0 bytes in 0 blocks
==5285==   total heap usage: 11 allocs, 11 frees, 222 bytes allocated
==5285== 
==5285== All heap blocks were freed -- no leaks are possible
==5285== 
==5285== For counts of detected and suppressed errors, rerun with: -v
==5285== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
$

0 コメント:

コメントを投稿