Fix [0] arrays

This commit is contained in:
Roman Venediktov 2024-06-26 15:11:18 +02:00
parent 94b31a70a4
commit 378b8e9785
2 changed files with 6 additions and 4 deletions

View file

@ -463,7 +463,8 @@ extern void *Lsubstring (aint* args /*void *subj, aint p, aint l*/) {
r = (data *)alloc_string(ll);
pop_extra_root((void**)&args[0]);
strncpy(r->contents, (char *)args[0] + pp, ll);
char *r_contents = r->contents;
strncpy(r_contents, (char *)args[0] + pp, ll);
POST_GC();
@ -751,7 +752,8 @@ extern void *Bstring (aint* args/*void *p*/) {
push_extra_root((void**)&args[0]);
s = LmakeString(BOX(n));
pop_extra_root((void**)&args[0]);
strncpy((char *)&TO_DATA(s)->contents, (char*)args[0], n + 1); // +1 because of '\0' in the end of C-strings
char *s_contents = (char *)&TO_DATA(s)->contents;
strncpy(s_contents, (char*)args[0], n + 1); // +1 because of '\0' in the end of C-strings
POST_GC();

View file

@ -79,7 +79,7 @@ typedef struct {
// last bit is used as MARK-BIT, the rest are used to store address where object should move
// last bit can be used because due to alignment we can assume that last two bits are always 0's
ptrt forward_address;
char contents[0];
char contents[];
} data;
typedef struct {
@ -95,7 +95,7 @@ typedef struct {
// last bit can be used because due to alignment we can assume that last two bits are always 0's
ptrt forward_address;
auint tag;
char contents[0];
char contents[];
} sexp;
#endif