sttemp

Simple template manager
git clone git://git.konyahin.xyz/sttemp
Log | Files | Refs | README | LICENSE

commit b909995d33dfa5fee05f34b9a37423b2c1760691
parent 7ded5b97e5735260e7e79eed0923b00be1bce267
Author: Anton Konyahin <me@konyahin.xyz>
Date:   Thu,  6 Jan 2022 20:53:57 +0300

minor fix

Diffstat:
Msrc/files.c | 2+-
Msrc/main.c | 3+--
Msrc/strings.c | 4+++-
Msrc/strings.h | 2++
4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -10,7 +10,7 @@ char* freadall(FILE* input, size_t* length) { do { buf = realloc(buf, BUF_SIZE + used); - len = fread(buf + used, 1, BUF_SIZE, input); + len = fread(buf + used, sizeof(char), BUF_SIZE, input); used = used + len; } while (len != 0); diff --git a/src/main.c b/src/main.c @@ -7,7 +7,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <fcntl.h> void show_usage() { printf("sttemp - simple template manager\n"); @@ -55,7 +54,7 @@ char* get_placeholder_value(const char* name, size_t length) { Token* token = malloc(sizeof(Token)); token->name = malloc(length); - strncpy(token->name, name, length); + memcpy(token->name, name, length); token->value = value; tokens = realloc(tokens, sizeof(Token) * ++tokens_len); diff --git a/src/strings.c b/src/strings.c @@ -1,5 +1,6 @@ -#include "strings.h" +/* See LICENSE file for copyright and license details. */ +#include "strings.h" char* strconcat(const char* first, const char* second) { size_t first_len = strlen(first); @@ -9,3 +10,4 @@ char* strconcat(const char* first, const char* second) { memcpy(buf + first_len, second, second_len + 1); return buf; } + diff --git a/src/strings.h b/src/strings.h @@ -1,3 +1,5 @@ +/* See LICENSE file for copyright and license details. */ + #include <stdlib.h> #include <string.h>