mirror of https://github.com/swig/swig
Zero initialize %array_functions and %array_class
This commit is contained in:
parent
cc56765a7a
commit
bdf71b0067
|
@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 3.0.11 (in progress)
|
||||
============================
|
||||
|
||||
2016-12-18: wsfulton
|
||||
Zero initialize arrays when using %array_class and %array_functions.
|
||||
|
||||
2016-12-18: t-ikegami
|
||||
[Python] Fix https://github.com/swig/swig/issues/446
|
||||
Python %array_class of carrays.i failed with -builtin option.
|
||||
|
|
|
@ -2,6 +2,10 @@ from li_cpointer_cpp import *
|
|||
|
||||
|
||||
p = new_intp()
|
||||
|
||||
if intp_value(p) != 0:
|
||||
raise RuntimeError("not initialized")
|
||||
|
||||
intp_assign(p, 3)
|
||||
|
||||
if intp_value(p) != 3:
|
||||
|
|
|
@ -2,6 +2,10 @@ from li_cpointer import *
|
|||
|
||||
|
||||
p = new_intp()
|
||||
|
||||
if intp_value(p) != 0:
|
||||
raise RuntimeError("not initialized")
|
||||
|
||||
intp_assign(p, 3)
|
||||
|
||||
if intp_value(p) != 3:
|
||||
|
|
|
@ -157,14 +157,14 @@ nocppval
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
# define %new_instance(Type...) (new Type)
|
||||
# define %new_instance(Type...) (new Type())
|
||||
# define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&)))
|
||||
# define %new_array(size,Type...) (new Type[size]())
|
||||
# define %new_copy_array(ptr,size,Type...) %reinterpret_cast(memcpy(new Type[size], ptr, sizeof(Type)*(size)), Type*)
|
||||
# define %delete(cptr) delete cptr
|
||||
# define %delete_array(cptr) delete[] cptr
|
||||
#else /* C case */
|
||||
# define %new_instance(Type...) (Type *)malloc(sizeof(Type))
|
||||
# define %new_instance(Type...) (Type *)calloc(1,sizeof(Type))
|
||||
# define %new_copy(val,Type...) (Type *)memcpy(%new_instance(Type),&val,sizeof(Type))
|
||||
# define %new_array(size,Type...) (Type *)calloc(size, sizeof(Type))
|
||||
# define %new_copy_array(ptr,size,Type...) (Type *)memcpy(malloc((size)*sizeof(Type)), ptr, sizeof(Type)*(size))
|
||||
|
|
Loading…
Reference in New Issue