summaryrefslogtreecommitdiff
path: root/string.h
blob: c2036a8e073e1e68f4fb1be5b25b851d811d6ce8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once

#include <stddef.h>


struct string {
  size_t len, cap;
  char *data;  // null-terminated
};

struct string string_make(const char *str);

void string_free(struct string s);

// Do not modify the length of the string.
char* string_read(struct string s);

// Returns original length.
size_t string_append(struct string *s, char *arg);

void string_truncate(struct string *s, size_t length);