Skip to content

Commit

Permalink
Compare with ffi.NULL instead of nil
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandlo committed Mar 9, 2024
1 parent df2e252 commit 7a23320
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/vips/Image_methods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ end

function Image.find_load(filename)
local name = vips_lib.vips_foreign_find_load(filename)
if name == nil then
return nil
if name == ffi.NULL then
return ffi.NULL
else
return ffi.string(name)
end
Expand All @@ -134,7 +134,7 @@ function Image.new_from_file(vips_filename, ...)
local options = to_string_copy(vips_lib.vips_filename_get_options(vips_filename))

local name = Image.find_load(filename)
if name == nil then
if name == ffi.NULL then
error(verror.get())
end

Expand All @@ -143,7 +143,7 @@ end

function Image.find_load_buffer(data)
local name = vips_lib.vips_foreign_find_load_buffer(data, #data)
if name == nil then
if name == ffi.NULL then
return nil
else
return ffi.string(name)
Expand All @@ -152,7 +152,7 @@ end

function Image.new_from_buffer(data, options, ...)
local name = Image.find_load_buffer(data)
if name == nil then
if name == ffi.NULL then
error(verror.get())
end

Expand All @@ -163,7 +163,7 @@ function Image.new_from_memory_ptr(data, size, width, height, bands, format)
local format_value = gvalue.to_enum(gvalue.band_format_type, format)
local vimage = vips_lib.vips_image_new_from_memory(data, size,
width, height, bands, format_value)
if vimage == nil then
if vimage == ffi.NULL then
error(verror.get())
end
return Image.new(vimage)
Expand Down Expand Up @@ -361,7 +361,7 @@ end

function Image_method:copy_memory()
local vimage = vips_lib.vips_image_copy_memory(self.vimage)
if vimage == nil then
if vimage == ffi.NULL then
error(verror.get())
end
return Image.new(vimage)
Expand All @@ -373,7 +373,7 @@ function Image_method:write_to_file(vips_filename, ...)
local filename = to_string_copy(vips_lib.vips_filename_get_filename(vips_filename))
local options = to_string_copy(vips_lib.vips_filename_get_options(vips_filename))
local name = vips_lib.vips_foreign_find_save(filename)
if name == nil then
if name == ffi.NULL then
error(verror.get())
end

Expand All @@ -384,7 +384,7 @@ end
function Image_method:write_to_buffer(format_string, ...)
local options = to_string_copy(vips_lib.vips_filename_get_options(format_string))
local name = vips_lib.vips_foreign_find_save_buffer(format_string)
if name == nil then
if name == ffi.NULL then
error(verror.get())
end

Expand Down
4 changes: 2 additions & 2 deletions src/vips/gvalue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ gvalue.get = function(gv)

local cstr = vips_lib.vips_enum_nick(gtype_raw, enum_value)

if cstr == nil then
if cstr == ffi.NULL then
error("value not in enum")
end

Expand All @@ -182,7 +182,7 @@ gvalue.get = function(gv)
elseif gtype == gvalue.gstr_type then
local cstr = gobject_lib.g_value_get_string(gv)

if cstr ~= nil then
if cstr ~= ffi.NULL then
result = ffi.string(cstr)
else
result = nil
Expand Down
4 changes: 2 additions & 2 deletions src/vips/voperation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ voperation.call = function(name, string_options, ...)
local call_args = { ... }

local vop = vips_lib.vips_operation_new(name)
if vop == nil then
if vop == ffi.NULL then
error("no such operation\n" .. verror.get())
end
vop = vop:new()
Expand Down Expand Up @@ -234,7 +234,7 @@ voperation.call = function(name, string_options, ...)
end

local vop2 = vips_lib.vips_cache_operation_build(vop)
if vop2 == nil then
if vop2 == ffi.NULL then
error("unable to call " .. name .. "\n" .. verror.get())
end
vop = vop2:new()
Expand Down

0 comments on commit 7a23320

Please sign in to comment.