@@ -78,6 +78,11 @@ def self.p2str(pointer)
78
78
class Image < Vips ::Object
79
79
alias_method :parent_get_typeof , :get_typeof
80
80
81
+ # FFI sets a pointer's size to this magic value if the size of the memory
82
+ # chunk the pointer points to is unknown to FFI.
83
+ UNKNOWN_POINTER_SIZE = FFI ::Pointer . new ( 1 ) . size
84
+ private_constant :UNKNOWN_POINTER_SIZE
85
+
81
86
private
82
87
83
88
# the layout of the VipsImage struct
@@ -367,7 +372,9 @@ def self.new_from_memory data, width, height, bands, format
367
372
# A pointer needs to know about the size of the memory it points to.
368
373
# If you have an address-only pointer, use the .slice method to wrap
369
374
# the pointer in a size aware pointer.
370
- raise Vips ::Error , "pointer has no size limit" unless data . size_limit?
375
+ if data . size == UNKNOWN_POINTER_SIZE
376
+ raise Vips ::Error , "size of memory is unknown"
377
+ end
371
378
size = data . size
372
379
else
373
380
size = data . bytesize
@@ -401,7 +408,9 @@ def self.new_from_memory_copy data, width, height, bands, format
401
408
format_number = GObject ::GValue . from_nick BAND_FORMAT_TYPE , format
402
409
403
410
if data . is_a? ( FFI ::Pointer )
404
- raise Vips ::Error , "pointer has no size limit" unless data . size_limit?
411
+ if data . size == UNKNOWN_POINTER_SIZE
412
+ raise Vips ::Error , "size of memory is unknown"
413
+ end
405
414
size = data . size
406
415
else
407
416
size = data . bytesize
0 commit comments