commit 6a6cbef986be8bf78e7d4711526f2a5073d8fd60 Author: Loic Nageleisen Date: Fri Feb 1 10:24:07 2013 +0100 basic object-like system in C diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..87e54c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +main +*.o diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..95071cb --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +all: main + +main: main.o + +clean: + rm -f main.o main diff --git a/main.c b/main.c new file mode 100644 index 0000000..3d64d12 --- /dev/null +++ b/main.c @@ -0,0 +1,29 @@ +#include +#include +#include + +struct Post_s { + char author[255]; + char body[2048]; +}; +typedef struct Post_s Post; + +Post *Post_alloc() { + return malloc(sizeof(Post)); +} + +void Post_init(Post *self) { + *self->author = '\0'; + *self->body = '\0'; +} + +void Post_dealloc(Post *self) { + free(self); +} + +int main(void) { + Post *post = Post_alloc(); + printf("%s\n\n%s\n", post->author, post->body); + Post_dealloc(post); + return 0; +}