From 25c9fef1d0d52cbb5b8220219019860c10e5d39f Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 10 Oct 2013 16:15:41 +0900 Subject: [PATCH] add pic_state structure --- include/picrin.h | 10 ++++++++++ src/main.c | 7 +++++++ src/state.c | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 include/picrin.h create mode 100644 src/state.c diff --git a/include/picrin.h b/include/picrin.h new file mode 100644 index 00000000..83663fa7 --- /dev/null +++ b/include/picrin.h @@ -0,0 +1,10 @@ +#ifndef PICRIN_H__ +#define PICRIN_H__ + +typedef struct { +} pic_state; + +pic_state *pic_open(); +void pic_close(pic_state *pic); + +#endif diff --git a/src/main.c b/src/main.c index 5d239ab2..ae8bf8c7 100644 --- a/src/main.c +++ b/src/main.c @@ -1,13 +1,18 @@ #include +#include "picrin.h" + #define LINE_MAX_LENGTH 256 int main() { + pic_state *pic; char line[LINE_MAX_LENGTH], last_char; int char_index; + pic = pic_open(); + while (1) { printf("> "); @@ -36,5 +41,7 @@ main() goto exit; exit: + pic_close(pic); + return 0; } diff --git a/src/state.c b/src/state.c new file mode 100644 index 00000000..a830608e --- /dev/null +++ b/src/state.c @@ -0,0 +1,19 @@ +#include + +#include "picrin.h" + +pic_state * +pic_open() +{ + pic_state *pic; + + pic = (pic_state *)calloc(sizeof(pic_state)); + + return pic; +} + +void +pic_close(pic_state *pic) +{ + free(pic); +}