aboutsummaryrefslogtreecommitdiff
path: root/test/unit/helpers.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-10-16 03:06:34 +0300
committerZyX <kp-pav@yandex.ru>2017-10-16 03:06:34 +0300
commit252a76db80dd846f9ccac4d7001697c12c009826 (patch)
tree329208f3d9c7302143ff6b5114a2fa88373613f6 /test/unit/helpers.lua
parentc03dc13bb74205d15a83ce3bd6ecb6b76b869878 (diff)
downloadrneovim-252a76db80dd846f9ccac4d7001697c12c009826.tar.gz
rneovim-252a76db80dd846f9ccac4d7001697c12c009826.tar.bz2
rneovim-252a76db80dd846f9ccac4d7001697c12c009826.zip
unittests: Free everything and check for memory leaks
Also improves error reporting.
Diffstat (limited to 'test/unit/helpers.lua')
-rw-r--r--test/unit/helpers.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index d3d14a5ca2..68ce9eed62 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -315,7 +315,7 @@ local function alloc_log_new()
eq(exp, self.log)
self:clear()
end
- function log:clear_tmp_allocs()
+ function log:clear_tmp_allocs(clear_null_frees)
local toremove = {}
local allocs = {}
for i, v in ipairs(self.log) do
@@ -327,6 +327,8 @@ local function alloc_log_new()
if v.func == 'free' then
toremove[#toremove + 1] = i
end
+ elseif clear_null_frees and v.args[1] == self.null then
+ toremove[#toremove + 1] = i
end
if v.func == 'realloc' then
allocs[tostring(v.ret)] = i
@@ -779,6 +781,12 @@ local function kvi_init(kvi)
return kvi
end
+local function kvi_destroy(kvi)
+ if kvi.items ~= kvi.init_array then
+ lib.xfree(kvi.items)
+ end
+end
+
local function kvi_new(ct)
return kvi_init(ffi.new(ct))
end
@@ -830,6 +838,7 @@ local module = {
sc = sc,
conv_enum = conv_enum,
array_size = array_sive,
+ kvi_destroy = kvi_destroy,
kvi_size = kvi_size,
kvi_init = kvi_init,
kvi_new = kvi_new,