Fix an issue introduced with the prop_stack change: It's not a good idea to
return a 3-value enum from a function declared to return bool. This broke the recurse case for prop_object_equals(). Instead, declare the object type equals routine to return a _prop_object_equals_rv_t. Give the same treatment to the object type free routines: declare them to return a _prop_object_free_rv_t, and consistently check those return values againt the enum type. Tidy up some whitespace while we're here.
This commit is contained in:
parent
108e11a80a
commit
4ce0dc3a15
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prop_array.c,v 1.18 2008/05/24 14:32:48 yamt Exp $ */
|
||||
/* $NetBSD: prop_array.c,v 1.19 2008/08/03 04:00:12 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
@ -53,18 +53,22 @@ _PROP_POOL_INIT(_prop_array_pool, sizeof(struct _prop_array), "proparay")
|
||||
_PROP_MALLOC_DEFINE(M_PROP_ARRAY, "prop array",
|
||||
"property array container object")
|
||||
|
||||
static int _prop_array_free(prop_stack_t, prop_object_t *);
|
||||
static void _prop_array_emergency_free(prop_object_t);
|
||||
static _prop_object_free_rv_t
|
||||
_prop_array_free(prop_stack_t, prop_object_t *);
|
||||
static void _prop_array_emergency_free(prop_object_t);
|
||||
static bool _prop_array_externalize(
|
||||
struct _prop_object_externalize_context *,
|
||||
void *);
|
||||
static bool _prop_array_equals(prop_object_t, prop_object_t,
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_array_equals(prop_object_t, prop_object_t,
|
||||
void **, void **,
|
||||
prop_object_t *, prop_object_t *);
|
||||
static void _prop_array_equals_finish(prop_object_t, prop_object_t);
|
||||
static prop_object_iterator_t _prop_array_iterator_locked(prop_array_t);
|
||||
static prop_object_t _prop_array_iterator_next_object_locked(void *);
|
||||
static void _prop_array_iterator_reset_locked(void *);
|
||||
static prop_object_iterator_t
|
||||
_prop_array_iterator_locked(prop_array_t);
|
||||
static prop_object_t
|
||||
_prop_array_iterator_next_object_locked(void *);
|
||||
static void _prop_array_iterator_reset_locked(void *);
|
||||
|
||||
static const struct _prop_object_type _prop_object_type_array = {
|
||||
.pot_type = PROP_TYPE_ARRAY,
|
||||
@ -87,7 +91,7 @@ struct _prop_array_iterator {
|
||||
|
||||
#define EXPAND_STEP 16
|
||||
|
||||
static int
|
||||
static _prop_object_free_rv_t
|
||||
_prop_array_free(prop_stack_t stack, prop_object_t *obj)
|
||||
{
|
||||
prop_array_t pa = *obj;
|
||||
@ -195,7 +199,7 @@ _prop_array_externalize(struct _prop_object_externalize_context *ctx,
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static bool
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_array_equals(prop_object_t v1, prop_object_t v2,
|
||||
void **stored_pointer1, void **stored_pointer2,
|
||||
prop_object_t *next_obj1, prop_object_t *next_obj2)
|
||||
@ -203,7 +207,7 @@ _prop_array_equals(prop_object_t v1, prop_object_t v2,
|
||||
prop_array_t array1 = v1;
|
||||
prop_array_t array2 = v2;
|
||||
uintptr_t idx;
|
||||
bool rv = _PROP_OBJECT_EQUALS_FALSE;
|
||||
_prop_object_equals_rv_t rv = _PROP_OBJECT_EQUALS_FALSE;
|
||||
|
||||
if (array1 == array2)
|
||||
return (_PROP_OBJECT_EQUALS_TRUE);
|
||||
@ -225,7 +229,7 @@ _prop_array_equals(prop_object_t v1, prop_object_t v2,
|
||||
if (array1->pa_count != array2->pa_count)
|
||||
goto out;
|
||||
if (idx == array1->pa_count) {
|
||||
rv = true;
|
||||
rv = _PROP_OBJECT_EQUALS_TRUE;
|
||||
goto out;
|
||||
}
|
||||
_PROP_ASSERT(idx < array1->pa_count);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prop_bool.c,v 1.15 2008/04/28 20:22:53 martin Exp $ */
|
||||
/* $NetBSD: prop_bool.c,v 1.16 2008/08/03 04:00:12 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
@ -43,11 +43,13 @@ static struct _prop_bool _prop_bool_false;
|
||||
_PROP_MUTEX_DECL_STATIC(_prop_bool_initialized_mutex)
|
||||
static bool _prop_bool_initialized;
|
||||
|
||||
static int _prop_bool_free(prop_stack_t, prop_object_t *);
|
||||
static _prop_object_free_rv_t
|
||||
_prop_bool_free(prop_stack_t, prop_object_t *);
|
||||
static bool _prop_bool_externalize(
|
||||
struct _prop_object_externalize_context *,
|
||||
void *);
|
||||
static bool _prop_bool_equals(prop_object_t, prop_object_t,
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_bool_equals(prop_object_t, prop_object_t,
|
||||
void **, void **,
|
||||
prop_object_t *, prop_object_t *);
|
||||
|
||||
@ -62,7 +64,7 @@ static const struct _prop_object_type _prop_object_type_bool = {
|
||||
((x) != NULL && (x)->pb_obj.po_type == &_prop_object_type_bool)
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
static _prop_object_free_rv_t
|
||||
_prop_bool_free(prop_stack_t stack, prop_object_t *obj)
|
||||
{
|
||||
/*
|
||||
@ -85,7 +87,7 @@ _prop_bool_externalize(struct _prop_object_externalize_context *ctx,
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static bool
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_bool_equals(prop_object_t v1, prop_object_t v2,
|
||||
void **stored_pointer1, void **stored_pointer2,
|
||||
prop_object_t *next_obj1, prop_object_t *next_obj2)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prop_data.c,v 1.12 2008/05/15 21:23:33 dyoung Exp $ */
|
||||
/* $NetBSD: prop_data.c,v 1.13 2008/08/03 04:00:12 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
@ -62,11 +62,13 @@ _PROP_POOL_INIT(_prop_data_pool, sizeof(struct _prop_data), "propdata")
|
||||
_PROP_MALLOC_DEFINE(M_PROP_DATA, "prop data",
|
||||
"property data container object")
|
||||
|
||||
static int _prop_data_free(prop_stack_t, prop_object_t *);
|
||||
static _prop_object_free_rv_t
|
||||
_prop_data_free(prop_stack_t, prop_object_t *);
|
||||
static bool _prop_data_externalize(
|
||||
struct _prop_object_externalize_context *,
|
||||
void *);
|
||||
static bool _prop_data_equals(prop_object_t, prop_object_t,
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_data_equals(prop_object_t, prop_object_t,
|
||||
void **, void **,
|
||||
prop_object_t *, prop_object_t *);
|
||||
|
||||
@ -81,7 +83,7 @@ static const struct _prop_object_type _prop_object_type_data = {
|
||||
((x) != NULL && (x)->pd_obj.po_type == &_prop_object_type_data)
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
static _prop_object_free_rv_t
|
||||
_prop_data_free(prop_stack_t stack, prop_object_t *obj)
|
||||
{
|
||||
prop_data_t pd = *obj;
|
||||
@ -173,7 +175,7 @@ _prop_data_externalize(struct _prop_object_externalize_context *ctx, void *v)
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static bool
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_data_equals(prop_object_t v1, prop_object_t v2,
|
||||
void **stored_pointer1, void **stored_pointer2,
|
||||
prop_object_t *next_obj1, prop_object_t *next_obj2)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prop_dictionary.c,v 1.31 2008/06/17 21:29:47 thorpej Exp $ */
|
||||
/* $NetBSD: prop_dictionary.c,v 1.32 2008/08/03 04:00:12 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
@ -104,23 +104,26 @@ _PROP_POOL_INIT(_prop_dictionary_pool, sizeof(struct _prop_dictionary),
|
||||
_PROP_MALLOC_DEFINE(M_PROP_DICT, "prop dictionary",
|
||||
"property dictionary container object")
|
||||
|
||||
static int _prop_dictionary_free(prop_stack_t, prop_object_t *);
|
||||
static void _prop_dictionary_emergency_free(prop_object_t);
|
||||
static _prop_object_free_rv_t
|
||||
_prop_dictionary_free(prop_stack_t, prop_object_t *);
|
||||
static void _prop_dictionary_emergency_free(prop_object_t);
|
||||
static bool _prop_dictionary_externalize(
|
||||
struct _prop_object_externalize_context *,
|
||||
void *);
|
||||
static bool _prop_dictionary_equals(prop_object_t, prop_object_t,
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_dictionary_equals(prop_object_t, prop_object_t,
|
||||
void **, void **,
|
||||
prop_object_t *, prop_object_t *);
|
||||
static void _prop_dictionary_equals_finish(prop_object_t, prop_object_t);
|
||||
static prop_object_iterator_t _prop_dictionary_iterator_locked(
|
||||
prop_dictionary_t);
|
||||
static prop_object_t _prop_dictionary_iterator_next_object_locked(void *);
|
||||
static prop_object_t _prop_dictionary_get_keysym(prop_dictionary_t,
|
||||
prop_dictionary_keysym_t,
|
||||
bool);
|
||||
static prop_object_t _prop_dictionary_get(prop_dictionary_t, const char *,
|
||||
bool);
|
||||
static prop_object_iterator_t
|
||||
_prop_dictionary_iterator_locked(prop_dictionary_t);
|
||||
static prop_object_t
|
||||
_prop_dictionary_iterator_next_object_locked(void *);
|
||||
static prop_object_t
|
||||
_prop_dictionary_get_keysym(prop_dictionary_t,
|
||||
prop_dictionary_keysym_t, bool);
|
||||
static prop_object_t
|
||||
_prop_dictionary_get(prop_dictionary_t, const char *, bool);
|
||||
|
||||
static const struct _prop_object_type _prop_object_type_dictionary = {
|
||||
.pot_type = PROP_TYPE_DICTIONARY,
|
||||
@ -131,11 +134,13 @@ static const struct _prop_object_type _prop_object_type_dictionary = {
|
||||
.pot_equals_finish = _prop_dictionary_equals_finish,
|
||||
};
|
||||
|
||||
static int _prop_dict_keysym_free(prop_stack_t, prop_object_t *);
|
||||
static _prop_object_free_rv_t
|
||||
_prop_dict_keysym_free(prop_stack_t, prop_object_t *);
|
||||
static bool _prop_dict_keysym_externalize(
|
||||
struct _prop_object_externalize_context *,
|
||||
void *);
|
||||
static bool _prop_dict_keysym_equals(prop_object_t, prop_object_t,
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_dict_keysym_equals(prop_object_t, prop_object_t,
|
||||
void **, void **,
|
||||
prop_object_t *, prop_object_t *);
|
||||
|
||||
@ -210,7 +215,7 @@ _prop_dict_keysym_put(prop_dictionary_keysym_t pdk)
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
static _prop_object_free_rv_t
|
||||
_prop_dict_keysym_free(prop_stack_t stack, prop_object_t *obj)
|
||||
{
|
||||
prop_dictionary_keysym_t pdk = *obj;
|
||||
@ -244,7 +249,7 @@ _prop_dict_keysym_externalize(struct _prop_object_externalize_context *ctx,
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static bool
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_dict_keysym_equals(prop_object_t v1, prop_object_t v2,
|
||||
void **stored_pointer1, void **stored_pointer2,
|
||||
prop_object_t *next_obj1, prop_object_t *next_obj2)
|
||||
@ -332,9 +337,7 @@ _prop_dict_keysym_alloc(const char *key)
|
||||
return (pdk);
|
||||
}
|
||||
|
||||
int dont_free = 1;
|
||||
|
||||
static int
|
||||
static _prop_object_free_rv_t
|
||||
_prop_dictionary_free(prop_stack_t stack, prop_object_t *obj)
|
||||
{
|
||||
prop_dictionary_t pd = *obj;
|
||||
@ -458,7 +461,7 @@ _prop_dictionary_externalize(struct _prop_object_externalize_context *ctx,
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static bool
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_dictionary_equals(prop_object_t v1, prop_object_t v2,
|
||||
void **stored_pointer1, void **stored_pointer2,
|
||||
prop_object_t *next_obj1, prop_object_t *next_obj2)
|
||||
@ -466,7 +469,7 @@ _prop_dictionary_equals(prop_object_t v1, prop_object_t v2,
|
||||
prop_dictionary_t dict1 = v1;
|
||||
prop_dictionary_t dict2 = v2;
|
||||
uintptr_t idx;
|
||||
bool rv = _PROP_OBJECT_EQUALS_FALSE;
|
||||
_prop_object_equals_rv_t rv = _PROP_OBJECT_EQUALS_FALSE;
|
||||
|
||||
if (dict1 == dict2)
|
||||
return (_PROP_OBJECT_EQUALS_TRUE);
|
||||
@ -1163,7 +1166,7 @@ prop_dictionary_keysym_equals(prop_dictionary_keysym_t pdk1,
|
||||
{
|
||||
if (!prop_object_is_dictionary_keysym(pdk1) ||
|
||||
!prop_object_is_dictionary_keysym(pdk2))
|
||||
return (_PROP_OBJECT_EQUALS_FALSE);
|
||||
return (false);
|
||||
|
||||
return (prop_object_equals(pdk1, pdk2));
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prop_number.c,v 1.18 2008/06/17 21:29:47 thorpej Exp $ */
|
||||
/* $NetBSD: prop_number.c,v 1.19 2008/08/03 04:00:12 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
@ -64,11 +64,13 @@ struct _prop_number {
|
||||
|
||||
_PROP_POOL_INIT(_prop_number_pool, sizeof(struct _prop_number), "propnmbr")
|
||||
|
||||
static int _prop_number_free(prop_stack_t, prop_object_t *);
|
||||
static _prop_object_free_rv_t
|
||||
_prop_number_free(prop_stack_t, prop_object_t *);
|
||||
static bool _prop_number_externalize(
|
||||
struct _prop_object_externalize_context *,
|
||||
void *);
|
||||
static bool _prop_number_equals(prop_object_t, prop_object_t,
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_number_equals(prop_object_t, prop_object_t,
|
||||
void **, void **,
|
||||
prop_object_t *, prop_object_t *);
|
||||
|
||||
@ -145,7 +147,7 @@ static bool _prop_number_tree_initialized;
|
||||
_PROP_MUTEX_DECL_STATIC(_prop_number_tree_mutex)
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
static _prop_object_free_rv_t
|
||||
_prop_number_free(prop_stack_t stack, prop_object_t *obj)
|
||||
{
|
||||
prop_number_t pn = *obj;
|
||||
@ -184,7 +186,7 @@ _prop_number_externalize(struct _prop_object_externalize_context *ctx,
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static bool
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_number_equals(prop_object_t v1, prop_object_t v2,
|
||||
void **stored_pointer1, void **stored_pointer2,
|
||||
prop_object_t *next_obj1, prop_object_t *next_obj2)
|
||||
@ -205,7 +207,7 @@ _prop_number_equals(prop_object_t v1, prop_object_t v2,
|
||||
* cannot be equal because they would have had pointer equality.
|
||||
*/
|
||||
if (num1->pn_value.pnv_is_unsigned == num2->pn_value.pnv_is_unsigned)
|
||||
return (_PROP_OBJECT_EQUALS_TRUE);
|
||||
return (_PROP_OBJECT_EQUALS_FALSE);
|
||||
|
||||
/*
|
||||
* We now have one signed value and one unsigned value. We can
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prop_object.c,v 1.21 2008/04/28 20:22:53 martin Exp $ */
|
||||
/* $NetBSD: prop_object.c,v 1.22 2008/08/03 04:00:12 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
@ -1035,7 +1035,8 @@ prop_object_release_emergency(prop_object_t obj)
|
||||
break;
|
||||
|
||||
_PROP_ASSERT(po->po_type);
|
||||
if ((po->po_type->pot_free)(NULL, &obj) == 0)
|
||||
if ((po->po_type->pot_free)(NULL, &obj) ==
|
||||
_PROP_OBJECT_FREE_DONE)
|
||||
break;
|
||||
|
||||
parent = po;
|
||||
@ -1129,7 +1130,7 @@ prop_object_equals_with_error(prop_object_t obj1, prop_object_t obj2,
|
||||
void *stored_pointer1, *stored_pointer2;
|
||||
prop_object_t next_obj1, next_obj2;
|
||||
struct _prop_stack stack;
|
||||
int ret;
|
||||
_prop_object_equals_rv_t ret;
|
||||
|
||||
_prop_stack_init(&stack);
|
||||
if (error_flag)
|
||||
@ -1145,8 +1146,9 @@ prop_object_equals_with_error(prop_object_t obj1, prop_object_t obj2,
|
||||
return (false);
|
||||
|
||||
continue_subtree:
|
||||
ret = (*po1->po_type->pot_equals)(obj1, obj2, &stored_pointer1, &stored_pointer2,
|
||||
&next_obj1, &next_obj2);
|
||||
ret = (*po1->po_type->pot_equals)(obj1, obj2,
|
||||
&stored_pointer1, &stored_pointer2,
|
||||
&next_obj1, &next_obj2);
|
||||
if (ret == _PROP_OBJECT_EQUALS_FALSE)
|
||||
goto finish;
|
||||
if (ret == _PROP_OBJECT_EQUALS_TRUE) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prop_object_impl.h,v 1.26 2008/05/24 14:24:04 yamt Exp $ */
|
||||
/* $NetBSD: prop_object_impl.h,v 1.27 2008/08/03 04:00:12 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
@ -47,32 +47,32 @@ struct _prop_object_externalize_context {
|
||||
unsigned int poec_depth; /* nesting depth */
|
||||
};
|
||||
|
||||
bool _prop_object_externalize_start_tag(
|
||||
bool _prop_object_externalize_start_tag(
|
||||
struct _prop_object_externalize_context *,
|
||||
const char *);
|
||||
bool _prop_object_externalize_end_tag(
|
||||
bool _prop_object_externalize_end_tag(
|
||||
struct _prop_object_externalize_context *,
|
||||
const char *);
|
||||
bool _prop_object_externalize_empty_tag(
|
||||
bool _prop_object_externalize_empty_tag(
|
||||
struct _prop_object_externalize_context *,
|
||||
const char *);
|
||||
bool _prop_object_externalize_append_cstring(
|
||||
bool _prop_object_externalize_append_cstring(
|
||||
struct _prop_object_externalize_context *,
|
||||
const char *);
|
||||
bool _prop_object_externalize_append_encoded_cstring(
|
||||
bool _prop_object_externalize_append_encoded_cstring(
|
||||
struct _prop_object_externalize_context *,
|
||||
const char *);
|
||||
bool _prop_object_externalize_append_char(
|
||||
bool _prop_object_externalize_append_char(
|
||||
struct _prop_object_externalize_context *,
|
||||
unsigned char);
|
||||
bool _prop_object_externalize_header(
|
||||
bool _prop_object_externalize_header(
|
||||
struct _prop_object_externalize_context *);
|
||||
bool _prop_object_externalize_footer(
|
||||
bool _prop_object_externalize_footer(
|
||||
struct _prop_object_externalize_context *);
|
||||
|
||||
struct _prop_object_externalize_context *
|
||||
_prop_object_externalize_context_alloc(void);
|
||||
void _prop_object_externalize_context_free(
|
||||
_prop_object_externalize_context_alloc(void);
|
||||
void _prop_object_externalize_context_free(
|
||||
struct _prop_object_externalize_context *);
|
||||
|
||||
typedef enum {
|
||||
@ -98,17 +98,17 @@ struct _prop_object_internalize_context {
|
||||
_prop_tag_type_t poic_tag_type;
|
||||
};
|
||||
|
||||
enum {
|
||||
typedef enum {
|
||||
_PROP_OBJECT_FREE_DONE,
|
||||
_PROP_OBJECT_FREE_RECURSE,
|
||||
_PROP_OBJECT_FREE_FAILED
|
||||
};
|
||||
} _prop_object_free_rv_t;
|
||||
|
||||
enum {
|
||||
typedef enum {
|
||||
_PROP_OBJECT_EQUALS_FALSE,
|
||||
_PROP_OBJECT_EQUALS_TRUE,
|
||||
_PROP_OBJECT_EQUALS_RECURSE
|
||||
};
|
||||
} _prop_object_equals_rv_t;
|
||||
|
||||
#define _PROP_EOF(c) ((c) == '\0')
|
||||
#define _PROP_ISSPACE(c) \
|
||||
@ -130,14 +130,14 @@ enum {
|
||||
(ctx)->poic_tagattrval_len,\
|
||||
(a), strlen(a))
|
||||
|
||||
bool _prop_object_internalize_find_tag(
|
||||
bool _prop_object_internalize_find_tag(
|
||||
struct _prop_object_internalize_context *,
|
||||
const char *, _prop_tag_type_t);
|
||||
bool _prop_object_internalize_match(const char *, size_t,
|
||||
bool _prop_object_internalize_match(const char *, size_t,
|
||||
const char *, size_t);
|
||||
prop_object_t _prop_object_internalize_by_tag(
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_object_internalize_decode_string(
|
||||
bool _prop_object_internalize_decode_string(
|
||||
struct _prop_object_internalize_context *,
|
||||
char *, size_t, size_t *, const char **);
|
||||
prop_object_t _prop_generic_internalize(const char *, const char *);
|
||||
@ -148,7 +148,7 @@ void _prop_object_internalize_context_free(
|
||||
struct _prop_object_internalize_context *);
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
bool _prop_object_externalize_write_file(const char *,
|
||||
bool _prop_object_externalize_write_file(const char *,
|
||||
const char *, size_t);
|
||||
|
||||
struct _prop_object_internalize_mapped_file {
|
||||
@ -162,30 +162,33 @@ void _prop_object_internalize_unmap_file(
|
||||
struct _prop_object_internalize_mapped_file *);
|
||||
#endif /* !_KERNEL && !_STANDALONE */
|
||||
|
||||
typedef bool (*prop_object_internalizer_t)(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
typedef bool (*prop_object_internalizer_continue_t)(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *, void *, prop_object_t);
|
||||
typedef bool (*prop_object_internalizer_t)(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
typedef bool (*prop_object_internalizer_continue_t)(prop_stack_t,
|
||||
prop_object_t *,
|
||||
struct _prop_object_internalize_context *,
|
||||
void *, prop_object_t);
|
||||
|
||||
/* These are here because they're required by shared code. */
|
||||
bool _prop_array_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_bool_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_data_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_dictionary_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_number_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_string_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_array_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_bool_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_data_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_dictionary_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_number_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
bool _prop_string_internalize(prop_stack_t, prop_object_t *,
|
||||
struct _prop_object_internalize_context *);
|
||||
|
||||
struct _prop_object_type {
|
||||
/* type indicator */
|
||||
uint32_t pot_type;
|
||||
/* func to free object */
|
||||
int (*pot_free)(prop_stack_t, prop_object_t *);
|
||||
_prop_object_free_rv_t
|
||||
(*pot_free)(prop_stack_t, prop_object_t *);
|
||||
/*
|
||||
* func to free the child returned by pot_free with stack == NULL.
|
||||
*
|
||||
@ -197,7 +200,8 @@ struct _prop_object_type {
|
||||
bool (*pot_extern)(struct _prop_object_externalize_context *,
|
||||
void *);
|
||||
/* func to test quality */
|
||||
bool (*pot_equals)(prop_object_t, prop_object_t,
|
||||
_prop_object_equals_rv_t
|
||||
(*pot_equals)(prop_object_t, prop_object_t,
|
||||
void **, void **,
|
||||
prop_object_t *, prop_object_t *);
|
||||
/*
|
||||
@ -214,9 +218,9 @@ struct _prop_object {
|
||||
uint32_t po_refcnt; /* reference count */
|
||||
};
|
||||
|
||||
void _prop_object_init(struct _prop_object *,
|
||||
const struct _prop_object_type *);
|
||||
void _prop_object_fini(struct _prop_object *);
|
||||
void _prop_object_init(struct _prop_object *,
|
||||
const struct _prop_object_type *);
|
||||
void _prop_object_fini(struct _prop_object *);
|
||||
|
||||
struct _prop_object_iterator {
|
||||
prop_object_t (*pi_next_object)(void *);
|
||||
@ -238,15 +242,15 @@ struct _prop_object_iterator {
|
||||
#include <sys/simplelock.h>
|
||||
#include <sys/rwlock.h>
|
||||
|
||||
#define _PROP_ASSERT(x) KASSERT(x)
|
||||
#define _PROP_ASSERT(x) KASSERT(x)
|
||||
|
||||
#define _PROP_MALLOC(s, t) malloc((s), (t), M_WAITOK)
|
||||
#define _PROP_CALLOC(s, t) malloc((s), (t), M_WAITOK | M_ZERO)
|
||||
#define _PROP_REALLOC(v, s, t) realloc((v), (s), (t), M_WAITOK)
|
||||
#define _PROP_FREE(v, t) free((v), (t))
|
||||
#define _PROP_MALLOC(s, t) malloc((s), (t), M_WAITOK)
|
||||
#define _PROP_CALLOC(s, t) malloc((s), (t), M_WAITOK | M_ZERO)
|
||||
#define _PROP_REALLOC(v, s, t) realloc((v), (s), (t), M_WAITOK)
|
||||
#define _PROP_FREE(v, t) free((v), (t))
|
||||
|
||||
#define _PROP_POOL_GET(p) pool_get(&(p), PR_WAITOK)
|
||||
#define _PROP_POOL_PUT(p, v) pool_put(&(p), (v))
|
||||
#define _PROP_POOL_GET(p) pool_get(&(p), PR_WAITOK)
|
||||
#define _PROP_POOL_PUT(p, v) pool_put(&(p), (v))
|
||||
|
||||
#define _PROP_POOL_INIT(p, s, d) \
|
||||
POOL_INIT(p, s, 0, 0, 0, d, &pool_allocator_nointr, IPL_NONE);
|
||||
@ -256,15 +260,15 @@ struct _prop_object_iterator {
|
||||
|
||||
#define _PROP_MUTEX_DECL_STATIC(x) \
|
||||
static struct simplelock x = SIMPLELOCK_INITIALIZER;
|
||||
#define _PROP_MUTEX_LOCK(x) simple_lock(&(x))
|
||||
#define _PROP_MUTEX_UNLOCK(x) simple_unlock(&(x))
|
||||
#define _PROP_MUTEX_LOCK(x) simple_lock(&(x))
|
||||
#define _PROP_MUTEX_UNLOCK(x) simple_unlock(&(x))
|
||||
|
||||
#define _PROP_RWLOCK_DECL(x) krwlock_t x ;
|
||||
#define _PROP_RWLOCK_INIT(x) rw_init(&(x))
|
||||
#define _PROP_RWLOCK_RDLOCK(x) rw_enter(&(x), RW_READER)
|
||||
#define _PROP_RWLOCK_WRLOCK(x) rw_enter(&(x), RW_WRITER)
|
||||
#define _PROP_RWLOCK_UNLOCK(x) rw_exit(&(x))
|
||||
#define _PROP_RWLOCK_DESTROY(x) rw_destroy(&(x))
|
||||
#define _PROP_RWLOCK_DECL(x) krwlock_t x ;
|
||||
#define _PROP_RWLOCK_INIT(x) rw_init(&(x))
|
||||
#define _PROP_RWLOCK_RDLOCK(x) rw_enter(&(x), RW_READER)
|
||||
#define _PROP_RWLOCK_WRLOCK(x) rw_enter(&(x), RW_WRITER)
|
||||
#define _PROP_RWLOCK_UNLOCK(x) rw_exit(&(x))
|
||||
#define _PROP_RWLOCK_DESTROY(x) rw_destroy(&(x))
|
||||
|
||||
#elif defined(_STANDALONE)
|
||||
|
||||
@ -277,15 +281,15 @@ struct _prop_object_iterator {
|
||||
void * _prop_standalone_calloc(size_t);
|
||||
void * _prop_standalone_realloc(void *, size_t);
|
||||
|
||||
#define _PROP_ASSERT(x) /* nothing */
|
||||
#define _PROP_ASSERT(x) /* nothing */
|
||||
|
||||
#define _PROP_MALLOC(s, t) alloc((s))
|
||||
#define _PROP_CALLOC(s, t) _prop_standalone_calloc((s))
|
||||
#define _PROP_REALLOC(v, s, t) _prop_standalone_realloc((v), (s))
|
||||
#define _PROP_FREE(v, t) dealloc((v), 0) /* XXX */
|
||||
#define _PROP_MALLOC(s, t) alloc((s))
|
||||
#define _PROP_CALLOC(s, t) _prop_standalone_calloc((s))
|
||||
#define _PROP_REALLOC(v, s, t) _prop_standalone_realloc((v), (s))
|
||||
#define _PROP_FREE(v, t) dealloc((v), 0) /* XXX */
|
||||
|
||||
#define _PROP_POOL_GET(p) alloc((p))
|
||||
#define _PROP_POOL_PUT(p, v) dealloc((v), (p))
|
||||
#define _PROP_POOL_GET(p) alloc((p))
|
||||
#define _PROP_POOL_PUT(p, v) dealloc((v), (p))
|
||||
|
||||
#define _PROP_POOL_INIT(p, s, d) static const size_t p = s;
|
||||
|
||||
@ -295,12 +299,12 @@ void * _prop_standalone_realloc(void *, size_t);
|
||||
#define _PROP_MUTEX_LOCK(x) /* nothing */
|
||||
#define _PROP_MUTEX_UNLOCK(x) /* nothing */
|
||||
|
||||
#define _PROP_RWLOCK_DECL(x) /* nothing */
|
||||
#define _PROP_RWLOCK_INIT(x) /* nothing */
|
||||
#define _PROP_RWLOCK_RDLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_WRLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_UNLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_DESTROY(x) /* nothing */
|
||||
#define _PROP_RWLOCK_DECL(x) /* nothing */
|
||||
#define _PROP_RWLOCK_INIT(x) /* nothing */
|
||||
#define _PROP_RWLOCK_RDLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_WRLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_UNLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_DESTROY(x) /* nothing */
|
||||
|
||||
#else
|
||||
|
||||
@ -314,15 +318,15 @@ void * _prop_standalone_realloc(void *, size_t);
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define _PROP_ASSERT(x) /*LINTED*/assert(x)
|
||||
#define _PROP_ASSERT(x) /*LINTED*/assert(x)
|
||||
|
||||
#define _PROP_MALLOC(s, t) malloc((s))
|
||||
#define _PROP_CALLOC(s, t) calloc(1, (s))
|
||||
#define _PROP_REALLOC(v, s, t) realloc((v), (s))
|
||||
#define _PROP_FREE(v, t) free((v))
|
||||
#define _PROP_MALLOC(s, t) malloc((s))
|
||||
#define _PROP_CALLOC(s, t) calloc(1, (s))
|
||||
#define _PROP_REALLOC(v, s, t) realloc((v), (s))
|
||||
#define _PROP_FREE(v, t) free((v))
|
||||
|
||||
#define _PROP_POOL_GET(p) malloc((p))
|
||||
#define _PROP_POOL_PUT(p, v) free((v))
|
||||
#define _PROP_POOL_GET(p) malloc((p))
|
||||
#define _PROP_POOL_PUT(p, v) free((v))
|
||||
|
||||
#define _PROP_POOL_INIT(p, s, d) static const size_t p = s;
|
||||
|
||||
@ -338,12 +342,12 @@ void * _prop_standalone_realloc(void *, size_t);
|
||||
#define _PROP_MUTEX_LOCK(x) mutex_lock(&(x))
|
||||
#define _PROP_MUTEX_UNLOCK(x) mutex_unlock(&(x))
|
||||
|
||||
#define _PROP_RWLOCK_DECL(x) rwlock_t x ;
|
||||
#define _PROP_RWLOCK_INIT(x) rwlock_init(&(x), NULL)
|
||||
#define _PROP_RWLOCK_RDLOCK(x) rwlock_rdlock(&(x))
|
||||
#define _PROP_RWLOCK_WRLOCK(x) rwlock_wrlock(&(x))
|
||||
#define _PROP_RWLOCK_UNLOCK(x) rwlock_unlock(&(x))
|
||||
#define _PROP_RWLOCK_DESTROY(x) rwlock_destroy(&(x))
|
||||
#define _PROP_RWLOCK_DECL(x) rwlock_t x ;
|
||||
#define _PROP_RWLOCK_INIT(x) rwlock_init(&(x), NULL)
|
||||
#define _PROP_RWLOCK_RDLOCK(x) rwlock_rdlock(&(x))
|
||||
#define _PROP_RWLOCK_WRLOCK(x) rwlock_wrlock(&(x))
|
||||
#define _PROP_RWLOCK_UNLOCK(x) rwlock_unlock(&(x))
|
||||
#define _PROP_RWLOCK_DESTROY(x) rwlock_destroy(&(x))
|
||||
#elif defined(HAVE_NBTOOL_CONFIG_H)
|
||||
/*
|
||||
* None of NetBSD's build tools are multi-threaded.
|
||||
@ -352,12 +356,12 @@ void * _prop_standalone_realloc(void *, size_t);
|
||||
#define _PROP_MUTEX_LOCK(x) /* nothing */
|
||||
#define _PROP_MUTEX_UNLOCK(x) /* nothing */
|
||||
|
||||
#define _PROP_RWLOCK_DECL(x) /* nothing */
|
||||
#define _PROP_RWLOCK_INIT(x) /* nothing */
|
||||
#define _PROP_RWLOCK_RDLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_WRLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_UNLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_DESTROY(x) /* nothing */
|
||||
#define _PROP_RWLOCK_DECL(x) /* nothing */
|
||||
#define _PROP_RWLOCK_INIT(x) /* nothing */
|
||||
#define _PROP_RWLOCK_RDLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_WRLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_UNLOCK(x) /* nothing */
|
||||
#define _PROP_RWLOCK_DESTROY(x) /* nothing */
|
||||
#else
|
||||
/*
|
||||
* Use pthread mutexes everywhere else.
|
||||
@ -365,15 +369,15 @@ void * _prop_standalone_realloc(void *, size_t);
|
||||
#include <pthread.h>
|
||||
#define _PROP_MUTEX_DECL_STATIC(x) \
|
||||
static pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;
|
||||
#define _PROP_MUTEX_LOCK(x) pthread_mutex_lock(&(x))
|
||||
#define _PROP_MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x))
|
||||
#define _PROP_MUTEX_LOCK(x) pthread_mutex_lock(&(x))
|
||||
#define _PROP_MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x))
|
||||
|
||||
#define _PROP_RWLOCK_DECL(x) pthread_rwlock_t x ;
|
||||
#define _PROP_RWLOCK_INIT(x) pthread_rwlock_init(&(x), NULL)
|
||||
#define _PROP_RWLOCK_RDLOCK(x) pthread_rwlock_rdlock(&(x))
|
||||
#define _PROP_RWLOCK_WRLOCK(x) pthread_rwlock_wrlock(&(x))
|
||||
#define _PROP_RWLOCK_UNLOCK(x) pthread_rwlock_unlock(&(x))
|
||||
#define _PROP_RWLOCK_DESTROY(x) pthread_rwlock_destroy(&(x))
|
||||
#define _PROP_RWLOCK_DECL(x) pthread_rwlock_t x ;
|
||||
#define _PROP_RWLOCK_INIT(x) pthread_rwlock_init(&(x), NULL)
|
||||
#define _PROP_RWLOCK_RDLOCK(x) pthread_rwlock_rdlock(&(x))
|
||||
#define _PROP_RWLOCK_WRLOCK(x) pthread_rwlock_wrlock(&(x))
|
||||
#define _PROP_RWLOCK_UNLOCK(x) pthread_rwlock_unlock(&(x))
|
||||
#define _PROP_RWLOCK_DESTROY(x) pthread_rwlock_destroy(&(x))
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL */
|
||||
@ -383,9 +387,9 @@ void * _prop_standalone_realloc(void *, size_t);
|
||||
*/
|
||||
#if defined(__NetBSD__)
|
||||
#include <sys/cdefs.h>
|
||||
#define _PROP_ARG_UNUSED __unused
|
||||
#define _PROP_ARG_UNUSED __unused
|
||||
#else
|
||||
#define _PROP_ARG_UNUSED /* delete */
|
||||
#define _PROP_ARG_UNUSED /* delete */
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
#endif /* _PROPLIB_PROP_OBJECT_IMPL_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: prop_string.c,v 1.10 2008/04/28 20:22:53 martin Exp $ */
|
||||
/* $NetBSD: prop_string.c,v 1.11 2008/08/03 04:00:12 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 The NetBSD Foundation, Inc.
|
||||
@ -51,13 +51,15 @@ _PROP_POOL_INIT(_prop_string_pool, sizeof(struct _prop_string), "propstng")
|
||||
_PROP_MALLOC_DEFINE(M_PROP_STRING, "prop string",
|
||||
"property string container object")
|
||||
|
||||
static int _prop_string_free(prop_stack_t, prop_object_t *);
|
||||
static _prop_object_free_rv_t
|
||||
_prop_string_free(prop_stack_t, prop_object_t *);
|
||||
static bool _prop_string_externalize(
|
||||
struct _prop_object_externalize_context *,
|
||||
void *);
|
||||
static bool _prop_string_equals(prop_object_t, prop_object_t,
|
||||
void **, void **,
|
||||
prop_object_t *, prop_object_t *);
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_string_equals(prop_object_t, prop_object_t,
|
||||
void **, void **,
|
||||
prop_object_t *, prop_object_t *);
|
||||
|
||||
static const struct _prop_object_type _prop_object_type_string = {
|
||||
.pot_type = PROP_TYPE_STRING,
|
||||
@ -71,7 +73,7 @@ static const struct _prop_object_type _prop_object_type_string = {
|
||||
#define prop_string_contents(x) ((x)->ps_immutable ? (x)->ps_immutable : "")
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
static _prop_object_free_rv_t
|
||||
_prop_string_free(prop_stack_t stack, prop_object_t *obj)
|
||||
{
|
||||
prop_string_t ps = *obj;
|
||||
@ -102,7 +104,7 @@ _prop_string_externalize(struct _prop_object_externalize_context *ctx,
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static bool
|
||||
static _prop_object_equals_rv_t
|
||||
_prop_string_equals(prop_object_t v1, prop_object_t v2,
|
||||
void **stored_pointer1, void **stored_pointer2,
|
||||
prop_object_t *next_obj1, prop_object_t *next_obj2)
|
||||
|
Loading…
Reference in New Issue
Block a user