diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-03-02 12:29:14 +0100 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-03-02 12:29:14 +0100 |
| commit | 74933654160064f9303551a6c012be6b88d5b626 (patch) | |
| tree | 95191a4335f1a59a407cde9cba010a6c59ebab41 /src/source.cc | |
| parent | df736f5a97b329377e45adb8d734fd58ea9b14ac (diff) | |
creating and removing buffer
Diffstat (limited to 'src/source.cc')
| -rw-r--r-- | src/source.cc | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/source.cc b/src/source.cc index 9234ea9..d714f29 100644 --- a/src/source.cc +++ b/src/source.cc @@ -4,9 +4,46 @@ #include "common.cc" #include "memory.cc" +typedef u32 Source_Id; + +struct Span { + Source_Id id; + usize start, end; + + Span(Source_Id id, usize start, usize end) : id(id), start(start), end(end) {} +}; + struct Buffer { - String content; String file; + String content; + Link link; +}; + +bool buffer_init(Buffer* buffer, const Allocator* allocator, const String* content_in, const String* file_in) { + String content, file; + bool ret = slice_copy(allocator, content_in, &content); + if(unlikely(ret == false)) return false; + + ret = slice_copy(allocator, file_in, &file); + if(unlikely(ret == false)) { + slice_deallocate(allocator, &content); + return false; + } + + buffer->file = file; + buffer->content = content; + buffer->link = {}; + return true; +} + +void buffer_deinit(Buffer* buffer, const Allocator* allocator) { + slice_deallocate(allocator, &buffer->file); + slice_deallocate(allocator, &buffer->content); +} + +struct Buffer_Stack { + Link* buffers; + usize nbuffers; }; #endif |
