aboutsummaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-08-21 22:02:23 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-08-21 22:02:23 +0100
commit49a3302fd67e1925b53935939f9a61f6d79b9978 (patch)
tree89699e002fc41e9b79cb65fcacf22b932299606f /sv.c
parent89c77a796d947186ae77a896dc9a99cc9fb4ee2b (diff)
downloadalisp-49a3302fd67e1925b53935939f9a61f6d79b9978.tar.gz
alisp-49a3302fd67e1925b53935939f9a61f6d79b9978.tar.bz2
alisp-49a3302fd67e1925b53935939f9a61f6d79b9978.zip
Split out tests into its own file
Also adjust the build system to do some more (cleaning, building, testing, running).
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/sv.c b/sv.c
new file mode 100644
index 0000000..7debd30
--- /dev/null
+++ b/sv.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2025 Aryadev Chavali
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Unlicense
+ * for details.
+
+ * You may distribute and modify this code under the terms of the
+ * Unlicense, which you should have received a copy of along with this
+ * program. If not, please go to <https://unlicense.org/>.
+
+ * Created: 2025-08-21
+ * Description: String views
+ */
+
+#include <malloc.h>
+#include <string.h>
+
+#include "./alisp.h"
+
+sv_t sv_copy(sv_t old)
+{
+ char *newstr = calloc(1, (old.size + 1) * sizeof(*newstr));
+ memcpy(newstr, old.data, old.size);
+ newstr[old.size] = '\0';
+ return SV(newstr, old.size);
+}