summaryrefslogtreecommitdiff
path: root/standard.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-07-31 22:11:13 +1000
committerquou <quou@disroot.org>2024-07-31 22:11:56 +1000
commit8d729883b3e134df8b9fc10f094df9fc3618bdb4 (patch)
tree8c6454372a350b98d06b74b912d56a937b992bf9 /standard.c
parent9fedd9336c48835495f74994d80795aa6e3fbecd (diff)
string_dup and string_len
Diffstat (limited to 'standard.c')
-rw-r--r--standard.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/standard.c b/standard.c
index 96677ea..afe6ad4 100644
--- a/standard.c
+++ b/standard.c
@@ -1,4 +1,5 @@
#include "maths.h"
+#include "memory.h"
#include "standard.h"
int string_equal(const char* a, const char* b) {
@@ -17,6 +18,19 @@ int string_copy(char* dst, const char* src) {
return i;
}
+int string_len(const char* s) {
+ int l;
+ for (l = 0; *s; s++, l++);
+ return l;
+}
+
+char* dup_string(Arena* a, const char* s) {
+ int size = string_len(s) + 1;
+ char* d = arena_alloc_aligned(a, size, 1);
+ string_copy(d, s);
+ return d;
+}
+
int int_to_buf(int n, char* buf) {
int i, sign, t;
unsigned n1;