1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 02:54:31 +03:00

GH-580 Fix memory leaks

This commit is contained in:
Tae Won Ha 2017-12-08 11:02:56 +01:00
parent 381063d13f
commit 64b54eee3c
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -274,10 +274,12 @@ static void server_ui_main(UIBridgeData *bridge, UI *ui) {
#pragma mark NeoVim's UI callbacks
static void server_ui_resize(UI *ui __unused, Integer width, Integer height) {
@autoreleasepool {
NSInteger values[] = {width, height};
NSData *data = [[NSData alloc] initWithBytes:values length:(2 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdResize data:data];
[data release];
}
}
static void server_ui_clear(UI *ui __unused) {
@ -289,6 +291,7 @@ static void server_ui_eol_clear(UI *ui __unused) {
}
static void server_ui_cursor_goto(UI *ui __unused, Integer row, Integer col) {
@autoreleasepool {
_put_row = row;
_put_column = col;
@ -302,6 +305,7 @@ static void server_ui_cursor_goto(UI *ui __unused, Integer row, Integer col) {
NSData *data = [[NSData alloc] initWithBytes:values length:(4 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetPosition data:data];
[data release];
}
}
static void server_ui_update_menu(UI *ui __unused) {
@ -330,26 +334,32 @@ static void server_ui_mode_info_set(UI *ui __unused, Boolean enabled __unused,
}
static void server_ui_mode_change(UI *ui __unused, String mode_str __unused, Integer mode) {
@autoreleasepool {
NSInteger value = mode;
NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdModeChange data:data];
[data release];
}
}
static void server_ui_set_scroll_region(UI *ui __unused, Integer top, Integer bot,
Integer left, Integer right) {
@autoreleasepool {
NSInteger values[] = {top, bot, left, right};
NSData *data = [[NSData alloc] initWithBytes:values length:(4 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetScrollRegion data:data];
[data release];
}
}
static void server_ui_scroll(UI *ui __unused, Integer count) {
@autoreleasepool {
NSInteger value = count;
NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdScroll data:data];
[data release];
}
}
static void server_ui_highlight_set(UI *ui __unused, HlAttrs attrs) {
@ -377,15 +387,19 @@ static void server_ui_highlight_set(UI *ui __unused, HlAttrs attrs) {
cellAttrs.special = attrs.special == -1 ? _default_special
: pun_type(unsigned int, attrs.special);
@autoreleasepool {
NSData *data = [[NSData alloc] initWithBytes:&cellAttrs length:sizeof(CellAttributes)];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetHighlightAttributes data:data];
[data release];
}
}
static void server_ui_put(UI *ui __unused, String str) {
NSString *string = [[NSString alloc] initWithBytes:str.data
length:str.size
encoding:NSUTF8StringEncoding];
@autoreleasepool {
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
if (_marked_text != nil && _marked_row == _put_row && _marked_column == _put_column) {
@ -411,6 +425,7 @@ static void server_ui_put(UI *ui __unused, String str) {
_put_column += 1;
[string release];
}
}
static void server_ui_bell(UI *ui __unused) {
@ -426,6 +441,7 @@ static void server_ui_flush(UI *ui __unused) {
}
static void server_ui_update_fg(UI *ui __unused, Integer fg) {
@autoreleasepool {
NSInteger value[1];
if (fg == -1) {
@ -443,9 +459,11 @@ static void server_ui_update_fg(UI *ui __unused, Integer fg) {
NSData *data = [[NSData alloc] initWithBytes:value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetForeground data:data];
[data release];
}
}
static void server_ui_update_bg(UI *ui __unused, Integer bg) {
@autoreleasepool {
NSInteger value[1];
if (bg == -1) {
@ -462,9 +480,11 @@ static void server_ui_update_bg(UI *ui __unused, Integer bg) {
NSData *data = [[NSData alloc] initWithBytes:value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetBackground data:data];
[data release];
}
}
static void server_ui_update_sp(UI *ui __unused, Integer sp) {
@autoreleasepool {
NSInteger value[2];
if (sp == -1) {
@ -481,9 +501,11 @@ static void server_ui_update_sp(UI *ui __unused, Integer sp) {
NSData *data = [[NSData alloc] initWithBytes:&value length:(1 * sizeof(NSInteger))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetSpecial data:data];
[data release];
}
}
static void server_ui_set_title(UI *ui __unused, String title) {
@autoreleasepool {
if (title.size == 0) {
return;
}
@ -492,9 +514,11 @@ static void server_ui_set_title(UI *ui __unused, String title) {
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetTitle
data:[string dataUsingEncoding:NSUTF8StringEncoding]];
[string release];
}
}
static void server_ui_set_icon(UI *ui __unused, String icon) {
@autoreleasepool {
if (icon.size == 0) {
return;
}
@ -503,6 +527,7 @@ static void server_ui_set_icon(UI *ui __unused, String icon) {
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetIcon
data:[string dataUsingEncoding:NSUTF8StringEncoding]];
[string release];
}
}
static void server_ui_stop(UI *ui __unused) {