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