Racket - NULL pointer handling

SWIG now converts a C/C++ NULL pointer into a null value by calling
scheme_make_null(), so that scheme's null? is true for a NULL C/C++
pointer value.

Consistency with Guile and needed for a pending commit for handling
NULL and std::unique_ptr.
This commit is contained in:
William S Fulton 2022-08-26 23:20:13 +01:00
commit 2cfd77b1c0
5 changed files with 31 additions and 9 deletions

View file

@ -144,16 +144,20 @@ mz_free_swig(void *p, void *data) {
static Scheme_Object *
SWIG_MzScheme_NewPointerObj(void *ptr, swig_type_info *type, int owner) {
struct swig_mz_proxy *new_proxy;
new_proxy = (struct swig_mz_proxy *) scheme_malloc(sizeof(struct swig_mz_proxy));
new_proxy->mztype = swig_type;
new_proxy->type = type;
new_proxy->object = ptr;
new_proxy->own = owner & SWIG_POINTER_OWN;
if (new_proxy->own) {
scheme_add_finalizer(new_proxy, mz_free_swig, NULL);
if (ptr) {
struct swig_mz_proxy *new_proxy;
new_proxy = (struct swig_mz_proxy *) scheme_malloc(sizeof(struct swig_mz_proxy));
new_proxy->mztype = swig_type;
new_proxy->type = type;
new_proxy->object = ptr;
new_proxy->own = owner & SWIG_POINTER_OWN;
if (new_proxy->own) {
scheme_add_finalizer(new_proxy, mz_free_swig, NULL);
}
return (Scheme_Object *) new_proxy;
} else {
return scheme_make_null();
}
return (Scheme_Object *) new_proxy;
}
static int