From 9579a803bfd8a95c42f0f1691af53a2cd27b5e3a Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 9 Oct 2015 22:39:21 -0400 Subject: [PATCH] WIP, changing how strings are allocated --- include/cyclone/types.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/cyclone/types.h b/include/cyclone/types.h index d05b63fa..3380b882 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -186,10 +186,13 @@ typedef struct {gc_header_type hdr; tag_type tag; double value;} double_type; /* Define string type */ typedef struct {gc_header_type hdr; tag_type tag; int len; char *str;} string_type; -//#define make_cstring(cs, len, s) \ -// string_type cs; cs.tag = string_tag; cs.len = len; cs.str = s; -// TODO: all of the dhalloc below needs to go away for this GC. maybe -// just plan on having strings be allocated separately like vectors. +// TODO: new way to allocate strings, but this requires changes to +// all functions that allocate strings, the GC, cgen, and maybe more. +#define make_string(cs, len, s) string_type cs; \ +{ cs.tag = string_tag; cs.len = len; \ + cs.str = alloca(sizeof(char) * (len + 1)); \ + strcpy(cs.str, s);} +// TODO: all of the dhalloc below needs to go away... #define make_string(cv,s) string_type cv; cv.tag = string_tag; \ { int len = strlen(s); cv.str = dhallocp; \ if ((dhallocp + len + 1) >= dhbottom + global_heap_size) { \