Skip to content

Commit

Permalink
Merge pull request #1056 from andrew-johnson-4/fix-buffer-deleted
Browse files Browse the repository at this point in the history
add back buffer to fix regressions
  • Loading branch information
andrew-johnson-4 authored Jan 8, 2025
2 parents 4ab9d84 + 5d2c66a commit 9df83c8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
16 changes: 8 additions & 8 deletions BOOTSTRAP/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,13 @@ void print_CL_ArrowNilF64(double uuid_000000000007fa7d);
double max_CL_ArrowF64ConsF64F64(double uuid_000000000007fa7e,double uuid_000000000007fa7f);
#line 36 "PLATFORM/C/LIB/f64.lm"
double min_CL_ArrowF64ConsF64F64(double uuid_000000000007fa80,double uuid_000000000007fa81);
#line 4 "/root/.lm/PLATFORM/C/LIB/buffer.lm"
#line 5 "PLATFORM/C/LIB/buffer.lm"
LM_Buffer new_SB_buffer_CL_ArrowBufferU64(unsigned long uuid_000000000007fa82);
#line 9 "/root/.lm/PLATFORM/C/LIB/buffer.lm"
#line 10 "PLATFORM/C/LIB/buffer.lm"
unsigned long _DT_calculate_SB_extension_SB_size_CL_ArrowU64U64(unsigned long uuid_000000000007fa84);
#line 17 "/root/.lm/PLATFORM/C/LIB/buffer.lm"
#line 18 "PLATFORM/C/LIB/buffer.lm"
LM_Buffer _DT_extend_CL_ArrowBufferConsU64Buffer(LM_Buffer uuid_000000000007fa86,unsigned long uuid_000000000007fa87);
#line 28 "/root/.lm/PLATFORM/C/LIB/buffer.lm"
#line 29 "PLATFORM/C/LIB/buffer.lm"
LM_Buffer _DT_write_CL_ArrowBufferConsU8Buffer(LM_Buffer uuid_000000000007fa8a,char uuid_000000000007fa8b);
#line 4 "PLATFORM/C/LIB/string.lm"
char head_SB_string_CL_ArrowU8String(char* uuid_000000000007fa8d);
Expand Down Expand Up @@ -2352,21 +2352,21 @@ void print_CL_ArrowNilF64(double uuid_000000000007fa7d){({(printf("%lf",uuid_000
double max_CL_ArrowF64ConsF64F64(double uuid_000000000007fa7e,double uuid_000000000007fa7f){return ((uuid_000000000007fa7e>=uuid_000000000007fa7f)?uuid_000000000007fa7e:uuid_000000000007fa7f);}
#line 36 "PLATFORM/C/LIB/f64.lm"
double min_CL_ArrowF64ConsF64F64(double uuid_000000000007fa80,double uuid_000000000007fa81){return ((uuid_000000000007fa80<=uuid_000000000007fa81)?uuid_000000000007fa80:uuid_000000000007fa81);}
#line 4 "/root/.lm/PLATFORM/C/LIB/buffer.lm"
#line 5 "PLATFORM/C/LIB/buffer.lm"
LM_Buffer new_SB_buffer_CL_ArrowBufferU64(unsigned long uuid_000000000007fa82){void* uuid_000000000007fa83;
return ({({uuid_000000000007fa83=(malloc(uuid_000000000007fa82));({});})
;
({LM_Buffer rvalue={.field_0=0,.field_1=uuid_000000000007fa82,.field_2=(0),.field_3=((char*)(uuid_000000000007fa83))};rvalue;});
});}
#line 9 "/root/.lm/PLATFORM/C/LIB/buffer.lm"
#line 10 "PLATFORM/C/LIB/buffer.lm"
unsigned long _DT_calculate_SB_extension_SB_size_CL_ArrowU64U64(unsigned long uuid_000000000007fa84){unsigned long uuid_000000000007fa85;
return ({({({uuid_000000000007fa85=(1024);({});})
;
({while((uuid_000000000007fa85<uuid_000000000007fa84)){((void)(({uuid_000000000007fa85=(uuid_000000000007fa85*(4));({});})));};});
});
uuid_000000000007fa85;
});}
#line 17 "/root/.lm/PLATFORM/C/LIB/buffer.lm"
#line 18 "PLATFORM/C/LIB/buffer.lm"
LM_Buffer _DT_extend_CL_ArrowBufferConsU64Buffer(LM_Buffer uuid_000000000007fa86,unsigned long uuid_000000000007fa87){unsigned long uuid_000000000007fa88;
void* uuid_000000000007fa89;
return ({((((uuid_000000000007fa86.field_2)+uuid_000000000007fa87)<(uuid_000000000007fa86.field_1))?({uuid_000000000007fa86=({LM_Buffer rvalue={.field_0=0,.field_1=(uuid_000000000007fa86.field_1),.field_2=((uuid_000000000007fa86.field_2)+uuid_000000000007fa87),.field_3=(uuid_000000000007fa86.field_3)};rvalue;});({});}):({({({uuid_000000000007fa88=(_DT_calculate_SB_extension_SB_size_CL_ArrowU64U64(((uuid_000000000007fa86.field_2)+uuid_000000000007fa87)));({});})
Expand All @@ -2378,7 +2378,7 @@ return ({((((uuid_000000000007fa86.field_2)+uuid_000000000007fa87)<(uuid_0000000
}));
uuid_000000000007fa86;
});}
#line 28 "/root/.lm/PLATFORM/C/LIB/buffer.lm"
#line 29 "PLATFORM/C/LIB/buffer.lm"
LM_Buffer _DT_write_CL_ArrowBufferConsU8Buffer(LM_Buffer uuid_000000000007fa8a,char uuid_000000000007fa8b){LM_Buffer uuid_000000000007fa8c;
return ({({({uuid_000000000007fa8c=(_DT_extend_CL_ArrowBufferConsU64Buffer(uuid_000000000007fa8a,(1)));({});})
;
Expand Down
34 changes: 34 additions & 0 deletions PLATFORM/C/LIB/buffer.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@


type Buffer (Buffer( ptr:U8[] , allocated:U64 , capacity:U64 ));

new-buffer := λ(: capacity U64). (: (
(let ptr (malloc capacity))
(Buffer( (as ptr U8[]) 0_u64 capacity ))
) Buffer);

.calculate-extension-size := λ(: min-size U64). (: (
(let try-size 1024_u64)
(while (<( try-size min-size )) (
(set try-size (*( try-size 4_u64 )))
))
try-size
) U64);

.extend := λ(: buff Buffer)(: sz U64). (: (
(if (<( (+( (.allocated buff) sz )) (.capacity buff) )) (
(set buff (Buffer( (.ptr buff) (+( (.allocated buff) sz )) (.capacity buff) )))
) (
(let new-sz (.calculate-extension-size( (+( (.allocated buff) sz )) )))
(let new-ptr (realloc( (.ptr buff) new-sz )))
(set buff (Buffer( (as new-ptr U8[]) (+( (.allocated buff) sz )) new-sz )))
))
buff
) Buffer);

.write := λ(: buff Buffer)(: data U8). (: (
(let out-buff (.extend( buff 1_u64 )))
(set[]( (as (.ptr out-buff) U8[]) (.allocated buff) data ))
out-buff
) Buffer);

0 comments on commit 9df83c8

Please sign in to comment.