| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
| |
On eb_backspace, when the upper line was non-null, line_cat followed
by line_free, and eb_delete_line only cleared the line_vec. However,
commit 2441e78 introduced an additional line_free in eb_delete_line to
fix a memory leak, which led to a double-free for that line. This
patch resolves that problem.
|
| |
|
|
| |
This patch removes the dependency on raylib when allocating memory.
|
| |
|
|
|
|
| |
The function eb_delete_line did not properly free the contents of the
entry when deleting an element from eb->line_vec. This patch fixes
that issue.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Each `struct line` now holds a pointer (`origin`) to its corresponding
line in the mmap'd file, along with its length (`origin_len`). The
`vec` field is no longer allocated for each line during
`eb_load_file`.
Instead, actual memory allocation and copying into `vec` occurs only
when an edit is made or when `line_get_string` is called (since a C
string is required). This behavior is handled via the internal inline
function `edit_happen`.
Also implement `vec_cat_raw` to `line_cat` when lazy `src`.
[minor]
Remove unused debug messages in editor.c.
|
| |
|
|
|
|
|
|
| |
Previously, line_init_from_buf called line_init followed by
vec_resize, which could result in up to two separate allocations. This
patch introduces vec_init_with_capacity, allowing the vector to be
initialized with the required capacity in a single step, reducing
allocation overhead.
|
| | |
|
| |
|
|
| |
It just bump size to 0.
|
| |
|
|
|
|
|
|
|
|
| |
This was rely on NULL-initialization of physically allocated
vector. When I remove that feature, it immediatly segfalt since
logically v->data[index] is not allocated so its not initialized by
NULL yet.
[minor]
add assert on vec_get to avoid this kind of stupid mistake.
|
| |
|
|
|
|
|
| |
instead, this will handle on *_resize for logically allocated segmants.
[minor]
refactor function vec_grow_to_size to proper name *_resize
|
| |
|
|
|
|
|
|
|
|
| |
It was "inserting" the new line to the current eb->cur_row
index. Which should just set or push (when inserting to the end of the
buffer) to the eb->vec[eb->cur_row].
[minor]
add assertion on vec_set.
add debug lines on draw loop.
|
| |
|
|
|
|
|
|
|
|
|
| |
Before deleting curr, it does not freeing it!
[minor]
optimize vec_delete; if sizeof v is 0, do not call memmove.
refactor line_init to clearly indicates both value are initialized to
0.
optimize line_cat; if src is empty (['\0']), do not call
Vec_char_delete or something.
|
| |
|
|
|
|
|
| |
After grow_to_size called, dest->size already growed. So calling
memcpy to dest->data + dest->size causes overrun. There was an anothor
problem... it does not update the dest->size either. Both are fixed
well.
|
| |
|
|
| |
multiply sizeof (type)
|
| |
|
|
| |
name vec_grow_size has chance to thought growing +dx size for vector.
|
| |
|
|
|
|
| |
[minor]
remove 'raylin.h' on makefile
fix vector.h to able to compile... (just a minor issues)
|
| |
|
|
| |
It would be clever decision to seperate cat last and insert middle.
|
| |
|
|
|
|
|
| |
makefile now handle each object and sources seperately to handle
header change gracefully.
and from now on, #DEBUG should declared inside of config.h
|
| |
|
|
|
| |
[minor]
refactor argument i to index for enhance readability
|
| |
|
|
|
| |
Mark eb_newline as TODO because it is not able to insert newline on
middle or end of the line.
|
| | |
|
| | |
|
| |
|
|
| |
minor: tide vector.h macros with proper indents
|
| |
|
|
|
|
|
|
| |
- Fixed incorrect `MemAlloc(sizeof(type *))` usage to properly allocate `sizeof(type)` for vector structs.
- Corrected `memmove` call in vector insert to account for type size and copy full range.
- Added `line_set_cursor()` to set line's cursor position before inserting new lines.
- Replaced `line_arr` with `line_vec` in editor buffer for clearer naming.
- Improved `DrawText` fallback behavior for NULL lines.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
- Rename vector type VEC -> Vec_char for clarity
- Update line.c to use renamed Vec_char API
- Add `line_insert` function for character insertion at arbitrary positions
- Define Vec_slinep as vector of line pointers in main.c
- Introduce `struct ed_buf` as an abstraction for a text buffer
- Implement `eb_insert`, `eb_free` and stub `eb_newline`, `eb_backspace`
- Update main loop to use `ed_buf` instead of standalone line/lines
- Fix vector insertion logic to support gaps and non-contiguous positions
- Change optimization level in makefile to -O0 for easier debugging
|
| | |
|
| | |
|
| | |
|
|
|
* vector.h: Add DEFINE_VECTOR macro for a header-only generic vector template
- Implements common operations: init, push, pop, set, get, len, grow
* line.[ch]:
- Replace fixed char-only vec with VEC (DEFINE_VECTOR(char)) instance
- Refactor memory allocation and method calls to use VEC_* macros
* makefile:
- Remove vec.o from OBJS (vec module is no longer used)
* vec.[ch] is now obsolete; new vector types (e.g., line *) can be defined
easily using a single DEFINE_VECTOR invocation
|