aboutsummaryrefslogtreecommitdiff
path: root/server/better_string.c
diff options
context:
space:
mode:
authorPreston Pan <ret2pop@gmail.com>2024-12-28 16:47:43 -0800
committerPreston Pan <ret2pop@gmail.com>2024-12-28 16:47:43 -0800
commit1fd608288ee47c2c560817f12f14b21069fed2f6 (patch)
treee6460b92dba5bb0d089c8c2a4e794e3504098359 /server/better_string.c
parent63f11aaec8d21844a07fd27003a992c102a3a297 (diff)
makefile and directory structure change completely to build client and server
Diffstat (limited to 'server/better_string.c')
-rw-r--r--server/better_string.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/server/better_string.c b/server/better_string.c
deleted file mode 100644
index 4413f77..0000000
--- a/server/better_string.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <better_string.h>
-#include <helpers.h>
-#include <stdlib.h>
-#include <string.h>
-
-string_t *init_string(const char *src) {
- string_t *s = safe_calloc(1, sizeof(string_t));
- size_t len = src ? strlen(src) : DEFAULT_STR_SIZE;
- size_t size = len * 2;
- s->buf = safe_calloc(size, sizeof(char));
- s->buf[0] = '\0';
-
- if (src)
- strcpy(s->buf, src);
- s->len = len;
- s->size = size;
- return s;
-}
-
-void string_push(string_t *s, char c) {
- if (s->len >= s->size - 2) {
- s->size *= 2;
- s->buf = safe_realloc(s->buf, s->size);
- }
- s->buf[s->len] = c;
- s->len++;
-}
-
-char string_pop(string_t *s) {
- char c = s->buf[s->len];
- s->len--;
- return c;
-}
-
-void string_concat_const(string_t *s1, const char *s2) {
- for (int i = 0; i < strlen(s2); i++) {
- string_push(s1, s2[i]);
- }
-}
-
-void string_concat(string_t *s1, string_t *s2) {
- for (int i = 0; i < s2->len; i++) {
- string_push(s1, s2->buf[i]);
- }
-}
-
-void string_free(void *x) {
- string_t *s = x;
- free(s->buf);
- free(s);
-}