Also guard object accessors against NULL (like we do foreign object types)
so that apps can use this construct safely: obj = prop_dictionary_get(dict, "value"); if (! prop_number_equals_integer(obj, 5)) { ... } Suggested by Iain Hibbert.
This commit is contained in:
parent
22b67e3c33
commit
beabdd9bdd
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: prop_array.c,v 1.5 2006/08/21 15:39:02 he Exp $ */
|
||||
/* $NetBSD: prop_array.c,v 1.6 2006/08/22 21:21:23 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
|
@ -73,7 +73,7 @@ static const struct _prop_object_type _prop_object_type_array = {
|
|||
};
|
||||
|
||||
#define prop_object_is_array(x) \
|
||||
((x)->pa_obj.po_type == &_prop_object_type_array)
|
||||
((x) != NULL && (x)->pa_obj.po_type == &_prop_object_type_array)
|
||||
|
||||
#define prop_array_is_immutable(x) (((x)->pa_flags & PA_F_IMMUTABLE) != 0)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: prop_bool.c,v 1.4 2006/08/21 04:13:28 thorpej Exp $ */
|
||||
/* $NetBSD: prop_bool.c,v 1.5 2006/08/22 21:21:23 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
|
@ -64,7 +64,7 @@ static const struct _prop_object_type _prop_object_type_bool = {
|
|||
};
|
||||
|
||||
#define prop_object_is_bool(x) \
|
||||
((x)->pb_obj.po_type == &_prop_object_type_bool)
|
||||
((x) != NULL && (x)->pb_obj.po_type == &_prop_object_type_bool)
|
||||
|
||||
static void
|
||||
_prop_bool_free(void *v)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: prop_data.c,v 1.3 2006/08/21 04:13:28 thorpej Exp $ */
|
||||
/* $NetBSD: prop_data.c,v 1.4 2006/08/22 21:21:23 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
|
@ -83,7 +83,7 @@ static const struct _prop_object_type _prop_object_type_data = {
|
|||
};
|
||||
|
||||
#define prop_object_is_data(x) \
|
||||
((x)->pd_obj.po_type == &_prop_object_type_data)
|
||||
((x) != NULL && (x)->pd_obj.po_type == &_prop_object_type_data)
|
||||
|
||||
static void
|
||||
_prop_data_free(void *v)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: prop_dictionary.c,v 1.10 2006/08/21 17:35:15 he Exp $ */
|
||||
/* $NetBSD: prop_dictionary.c,v 1.11 2006/08/22 21:21:23 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
|
@ -137,9 +137,9 @@ static const struct _prop_object_type _prop_object_type_dict_keysym = {
|
|||
};
|
||||
|
||||
#define prop_object_is_dictionary(x) \
|
||||
((x)->pd_obj.po_type == &_prop_object_type_dictionary)
|
||||
((x) != NULL && (x)->pd_obj.po_type == &_prop_object_type_dictionary)
|
||||
#define prop_object_is_dictionary_keysym(x) \
|
||||
((x)->pdk_obj.po_type == &_prop_object_type_dict_keysym)
|
||||
((x) != NULL && (x)->pdk_obj.po_type == &_prop_object_type_dict_keysym)
|
||||
|
||||
#define prop_dictionary_is_immutable(x) \
|
||||
(((x)->pd_flags & PD_F_IMMUTABLE) != 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: prop_number.c,v 1.4 2006/08/21 04:13:28 thorpej Exp $ */
|
||||
/* $NetBSD: prop_number.c,v 1.5 2006/08/22 21:21:23 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
|
@ -72,7 +72,7 @@ static const struct _prop_object_type _prop_object_type_number = {
|
|||
};
|
||||
|
||||
#define prop_object_is_number(x) \
|
||||
((x)->pn_obj.po_type == &_prop_object_type_number)
|
||||
((x) != NULL && (x)->pn_obj.po_type == &_prop_object_type_number)
|
||||
|
||||
static void
|
||||
_prop_number_free(void *v)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: prop_string.c,v 1.3 2006/08/21 04:13:28 thorpej Exp $ */
|
||||
/* $NetBSD: prop_string.c,v 1.4 2006/08/22 21:21:23 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
|
@ -72,7 +72,7 @@ static const struct _prop_object_type _prop_object_type_string = {
|
|||
};
|
||||
|
||||
#define prop_object_is_string(x) \
|
||||
((x)->ps_obj.po_type == &_prop_object_type_string)
|
||||
((x) != NULL && (x)->ps_obj.po_type == &_prop_object_type_string)
|
||||
#define prop_string_contents(x) ((x)->ps_immutable ? (x)->ps_immutable : "")
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue