leaks fix
This commit is contained in:
@@ -64,6 +64,8 @@ void bufferRowInsertBytes(struct buffer_t *buffer, row_t *row, int at, const cha
|
||||
void bufferRowDelByte(struct buffer_t *buffer, row_t *row, int at, int n);
|
||||
void bufferInsertRow(struct buffer_t *buffer, int at, char *s, size_t len);
|
||||
void bufferFreeRow(row_t *row);
|
||||
char* bufferToText(struct buffer_t* buf);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -118,6 +118,7 @@ typedef enum
|
||||
LSP_NOT_STARTED = 0,
|
||||
LSP_INITIALIZING,
|
||||
LSP_READY,
|
||||
LSP_SHUTTING_DOWN,
|
||||
LSP_SHUTDOWN,
|
||||
} LspState;
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
project('beluga', 'c',
|
||||
version : '2.3',
|
||||
default_options : [
|
||||
'c_std=none',
|
||||
'c_std=c99',
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
+24
-3
@@ -64,6 +64,7 @@ int bufferCreate(const char* path, enum bufferStatus_e state)
|
||||
{
|
||||
appDebug("Creating new buffer");
|
||||
char* filename = basename((char*)path);
|
||||
char* fullname;
|
||||
// Check if file is already open
|
||||
const int existing_id = bufferFindByFilename(path);
|
||||
if (existing_id != -1)
|
||||
@@ -91,8 +92,10 @@ int bufferCreate(const char* path, enum bufferStatus_e state)
|
||||
free(new_buf->filename);
|
||||
return -1;
|
||||
}
|
||||
realpath(path, new_buf->fullname);
|
||||
new_buf->path = dirname(new_buf->fullname);
|
||||
fullname = malloc(PATH_MAX * sizeof(char));
|
||||
realpath(path, fullname);
|
||||
new_buf->fullname = strdup(fullname);
|
||||
new_buf->path = dirname(fullname);
|
||||
new_buf->type = FILE_BUFF;
|
||||
new_buf->state = state;
|
||||
new_buf->x = 0;
|
||||
@@ -100,6 +103,8 @@ int bufferCreate(const char* path, enum bufferStatus_e state)
|
||||
new_buf->dirty = 0; // New file starts clean
|
||||
new_buf->b_lsp_open = 0;
|
||||
|
||||
free(fullname);
|
||||
|
||||
// Load file content using existing editorOpen
|
||||
editorOpen(new_buf);
|
||||
E.number_of_buffer++;
|
||||
@@ -495,7 +500,6 @@ void bufferInsertNewLine(void)
|
||||
EditorPane* active = splitScreenGetActivePane();
|
||||
struct buffer_t* buf = bufferFindById(active->buffer_id);
|
||||
|
||||
appDebug("buf x %d\n", buf->x);
|
||||
|
||||
if (buf->y >= buf->numrows)
|
||||
{
|
||||
@@ -522,3 +526,20 @@ void bufferInsertNewLine(void)
|
||||
buf->x = 0;
|
||||
appDebug("Insert new line done\n");
|
||||
}
|
||||
|
||||
char* bufferToText(struct buffer_t* buf)
|
||||
{
|
||||
int total = 0;
|
||||
for (int i = 0; i < buf->numrows; i++)
|
||||
total += buf->row[i].size + 1; // +1 for \n
|
||||
char* text = malloc(total + 1);
|
||||
char* p = text;
|
||||
for (int i = 0; i < buf->numrows; i++)
|
||||
{
|
||||
memcpy(p, buf->row[i].chars, buf->row[i].size);
|
||||
p += buf->row[i].size;
|
||||
*p++ = '\n';
|
||||
}
|
||||
*p = '\0';
|
||||
return text;
|
||||
}
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
#include "../include/input.h"
|
||||
#include "../include/terminal.h"
|
||||
#include "../include/split_screen.h"
|
||||
#include "../include/lisp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -185,13 +186,13 @@ Lisp editorQuit(Lisp args, LispError* e, LispContext ctx)
|
||||
--E.quit_times_buffer;
|
||||
return lisp_null();
|
||||
}
|
||||
disableRawMode();
|
||||
bFree_structs();
|
||||
write(STDOUT_FILENO, "\x1b[2J", 4);
|
||||
write(STDOUT_FILENO, CURSOR_TOP_LEFT, 3);
|
||||
lspShutdown(E.lsp_client);
|
||||
lisp_shutdown(E.ctx);
|
||||
// deInitEditor();
|
||||
disableRawMode();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
+409
-439
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user