From: Niki Roo Date: Fri, 4 Apr 2025 20:49:21 +0000 (+0200) Subject: example: fix tabulation X-Git-Url: http://git.nikiroo.be/?a=commitdiff_plain;h=bd5c10662daeba1da2f676fe8beff3c1322740bb;p=template.git example: fix tabulation --- diff --git a/example.c b/example.c index 52883f5..12ff3c4 100644 --- a/example.c +++ b/example.c @@ -23,28 +23,31 @@ #include "example.h" example_t *new_example() { - example_t *self = malloc(sizeof(example_t)); - if (!init_example(self)) { - free(self); - self = NULL; - } + example_t *self = malloc(sizeof(example_t)); + if (!init_example(self)) { + free(self); + self = NULL; + } - return self; + return self; } int init_example(example_t *self) { - strcpy(self->CNAME, "[exampl]"); + size_t sz = sizeof(self->CNAME); + strncpy(self->CNAME, "[example ", sz); + self->CNAME[sz - 2] = ']'; + self->CNAME[sz - 1] = '\0'; return 1; } void free_example(example_t *self) { - if (self) - uninit_example(self); + if (self) + uninit_example(self); - free(self); + free(self); } void uninit_example(example_t *self) { - self->CNAME[0] = '!'; + self->CNAME[0] = '!'; } diff --git a/example.h b/example.h index 49c47c7..a34e623 100644 --- a/example.h +++ b/example.h @@ -18,9 +18,9 @@ * blablabla */ typedef struct { - char CNAME[10]; - size_t count; - void *priv; + char CNAME[10]; + size_t count; + void *priv; } example_t; /**