example: fix tabulation
authorNiki Roo <niki@nikiroo.be>
Fri, 4 Apr 2025 20:49:21 +0000 (22:49 +0200)
committerNiki Roo <niki@nikiroo.be>
Fri, 4 Apr 2025 20:49:21 +0000 (22:49 +0200)
example.c
example.h

index 52883f5ad5693e27eb5a4c3e9b99796bec48accf..12ff3c4d4d4abbc693d34794384a2562c7ca8d5c 100644 (file)
--- a/example.c
+++ b/example.c
 #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] = '!';
 }
 
index 49c47c7b07353ef5b1039e37830d937cc8a5590d..a34e62391c41ff16e2d5849f0a69034149680397 100644 (file)
--- 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;
 
 /**