1 /* $NetBSD: prop_object.c,v 1.26 2009/03/30 07:42:51 haad Exp $ */
4 * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <prop/prop_object.h>
33 #include "prop_object_impl.h"
35 #if !defined(_KERNEL) && !defined(_STANDALONE)
43 #include <sys/atomic.h>
47 _prop_standalone_calloc(size_t size)
59 _prop_standalone_realloc(void *v, size_t size)
65 memcpy(rv, v, size); /* XXX */
66 dealloc(v, 0); /* XXX */
71 #endif /* _STANDALONE */
74 * _prop_object_init --
75 * Initialize an object. Called when sub-classes create
79 _prop_object_init(struct _prop_object *po, const struct _prop_object_type *pot)
87 * _prop_object_fini --
88 * Finalize an object. Called when sub-classes destroy
93 _prop_object_fini(struct _prop_object *po _PROP_ARG_UNUSED)
95 /* Nothing to do, currently. */
99 * _prop_object_externalize_start_tag --
100 * Append an XML-style start tag to the externalize buffer.
103 _prop_object_externalize_start_tag(
104 struct _prop_object_externalize_context *ctx, const char *tag)
108 for (i = 0; i < ctx->poec_depth; i++) {
109 if (_prop_object_externalize_append_char(ctx, '\t') == false)
112 if (_prop_object_externalize_append_char(ctx, '<') == false ||
113 _prop_object_externalize_append_cstring(ctx, tag) == false ||
114 _prop_object_externalize_append_char(ctx, '>') == false)
121 * _prop_object_externalize_end_tag --
122 * Append an XML-style end tag to the externalize buffer.
125 _prop_object_externalize_end_tag(
126 struct _prop_object_externalize_context *ctx, const char *tag)
129 if (_prop_object_externalize_append_char(ctx, '<') == false ||
130 _prop_object_externalize_append_char(ctx, '/') == false ||
131 _prop_object_externalize_append_cstring(ctx, tag) == false ||
132 _prop_object_externalize_append_char(ctx, '>') == false ||
133 _prop_object_externalize_append_char(ctx, '\n') == false)
140 * _prop_object_externalize_empty_tag --
141 * Append an XML-style empty tag to the externalize buffer.
144 _prop_object_externalize_empty_tag(
145 struct _prop_object_externalize_context *ctx, const char *tag)
149 for (i = 0; i < ctx->poec_depth; i++) {
150 if (_prop_object_externalize_append_char(ctx, '\t') == false)
154 if (_prop_object_externalize_append_char(ctx, '<') == false ||
155 _prop_object_externalize_append_cstring(ctx, tag) == false ||
156 _prop_object_externalize_append_char(ctx, '/') == false ||
157 _prop_object_externalize_append_char(ctx, '>') == false ||
158 _prop_object_externalize_append_char(ctx, '\n') == false)
165 * _prop_object_externalize_append_cstring --
166 * Append a C string to the externalize buffer.
169 _prop_object_externalize_append_cstring(
170 struct _prop_object_externalize_context *ctx, const char *cp)
173 while (*cp != '\0') {
174 if (_prop_object_externalize_append_char(ctx,
175 (unsigned char) *cp) == false)
184 * _prop_object_externalize_append_encoded_cstring --
185 * Append an encoded C string to the externalize buffer.
188 _prop_object_externalize_append_encoded_cstring(
189 struct _prop_object_externalize_context *ctx, const char *cp)
192 while (*cp != '\0') {
195 if (_prop_object_externalize_append_cstring(ctx,
200 if (_prop_object_externalize_append_cstring(ctx,
205 if (_prop_object_externalize_append_cstring(ctx,
210 if (_prop_object_externalize_append_char(ctx,
211 (unsigned char) *cp) == false)
221 #define BUF_EXPAND 256
224 * _prop_object_externalize_append_char --
225 * Append a single character to the externalize buffer.
228 _prop_object_externalize_append_char(
229 struct _prop_object_externalize_context *ctx, unsigned char c)
232 _PROP_ASSERT(ctx->poec_capacity != 0);
233 _PROP_ASSERT(ctx->poec_buf != NULL);
234 _PROP_ASSERT(ctx->poec_len <= ctx->poec_capacity);
236 if (ctx->poec_len == ctx->poec_capacity) {
237 char *cp = _PROP_REALLOC(ctx->poec_buf,
238 ctx->poec_capacity + BUF_EXPAND,
242 ctx->poec_capacity = ctx->poec_capacity + BUF_EXPAND;
246 ctx->poec_buf[ctx->poec_len++] = c;
252 * _prop_object_externalize_header --
253 * Append the standard XML header to the externalize buffer.
256 _prop_object_externalize_header(struct _prop_object_externalize_context *ctx)
258 static const char _plist_xml_header[] =
259 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
260 "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n";
262 if (_prop_object_externalize_append_cstring(ctx,
263 _plist_xml_header) == false ||
264 _prop_object_externalize_start_tag(ctx,
265 "plist version=\"1.0\"") == false ||
266 _prop_object_externalize_append_char(ctx, '\n') == false)
273 * _prop_object_externalize_footer --
274 * Append the standard XML footer to the externalize buffer. This
275 * also NUL-terminates the buffer.
278 _prop_object_externalize_footer(struct _prop_object_externalize_context *ctx)
281 if (_prop_object_externalize_end_tag(ctx, "plist") == false ||
282 _prop_object_externalize_append_char(ctx, '\0') == false)
289 * _prop_object_externalize_context_alloc --
290 * Allocate an externalize context.
292 struct _prop_object_externalize_context *
293 _prop_object_externalize_context_alloc(void)
295 struct _prop_object_externalize_context *ctx;
297 ctx = _PROP_MALLOC(sizeof(*ctx), M_TEMP);
299 ctx->poec_buf = _PROP_MALLOC(BUF_EXPAND, M_TEMP);
300 if (ctx->poec_buf == NULL) {
301 _PROP_FREE(ctx, M_TEMP);
305 ctx->poec_capacity = BUF_EXPAND;
312 * _prop_object_externalize_context_free --
313 * Free an externalize context.
316 _prop_object_externalize_context_free(
317 struct _prop_object_externalize_context *ctx)
320 /* Buffer is always freed by the caller. */
321 _PROP_FREE(ctx, M_TEMP);
325 * _prop_object_internalize_skip_comment --
326 * Skip the body and end tag of a comment.
329 _prop_object_internalize_skip_comment(
330 struct _prop_object_internalize_context *ctx)
332 const char *cp = ctx->poic_cp;
334 while (!_PROP_EOF(*cp)) {
338 ctx->poic_cp = cp + 3;
344 return (false); /* ran out of buffer */
348 * _prop_object_internalize_find_tag --
349 * Find the next tag in an XML stream. Optionally compare the found
350 * tag to an expected tag name. State of the context is undefined
351 * if this routine returns false. Upon success, the context points
352 * to the first octet after the tag.
355 _prop_object_internalize_find_tag(struct _prop_object_internalize_context *ctx,
356 const char *tag, _prop_tag_type_t type)
362 taglen = strlen(tag);
370 * Find the start of the tag.
372 while (_PROP_ISSPACE(*cp))
380 ctx->poic_tag_start = cp++;
385 if (cp[1] != '-' || cp[2] != '-')
388 * Comment block -- only allowed if we are allowed to
389 * return a start tag.
391 if (type == _PROP_TAG_TYPE_END)
393 ctx->poic_cp = cp + 3;
394 if (_prop_object_internalize_skip_comment(ctx) == false)
400 if (type != _PROP_TAG_TYPE_END &&
401 type != _PROP_TAG_TYPE_EITHER)
406 ctx->poic_tag_type = _PROP_TAG_TYPE_END;
408 if (type != _PROP_TAG_TYPE_START &&
409 type != _PROP_TAG_TYPE_EITHER)
411 ctx->poic_tag_type = _PROP_TAG_TYPE_START;
414 ctx->poic_tagname = cp;
416 while (!_PROP_ISSPACE(*cp) && *cp != '/' && *cp != '>')
421 ctx->poic_tagname_len = cp - ctx->poic_tagname;
423 /* Make sure this is the tag we're looking for. */
425 (taglen != ctx->poic_tagname_len ||
426 memcmp(tag, ctx->poic_tagname, taglen) != 0))
429 /* Check for empty tag. */
431 if (ctx->poic_tag_type != _PROP_TAG_TYPE_START)
432 return(false); /* only valid on start tags */
433 ctx->poic_is_empty_element = true;
435 if (_PROP_EOF(*cp) || *cp != '>')
438 ctx->poic_is_empty_element = false;
440 /* Easy case of no arguments. */
442 ctx->poic_tagattr = NULL;
443 ctx->poic_tagattr_len = 0;
444 ctx->poic_tagattrval = NULL;
445 ctx->poic_tagattrval_len = 0;
446 ctx->poic_cp = cp + 1;
450 _PROP_ASSERT(!_PROP_EOF(*cp));
455 while (_PROP_ISSPACE(*cp))
460 ctx->poic_tagattr = cp;
462 while (!_PROP_ISSPACE(*cp) && *cp != '=')
467 ctx->poic_tagattr_len = cp - ctx->poic_tagattr;
476 ctx->poic_tagattrval = cp;
481 ctx->poic_tagattrval_len = cp - ctx->poic_tagattrval;
487 ctx->poic_cp = cp + 1;
492 * _prop_object_internalize_decode_string --
493 * Decode an encoded string.
496 _prop_object_internalize_decode_string(
497 struct _prop_object_internalize_context *ctx,
498 char *target, size_t targsize, size_t *sizep,
515 if ((c = *src) == '&') {
522 } else if (src[1] == 'l' &&
527 } else if (src[1] == 'g' &&
532 } else if (src[1] == 'a' &&
539 } else if (src[1] == 'q' &&
551 if (tarindex >= targsize)
553 target[tarindex] = c;
558 _PROP_ASSERT(*src == '<');
568 * _prop_object_internalize_match --
569 * Returns true if the two character streams match.
572 _prop_object_internalize_match(const char *str1, size_t len1,
573 const char *str2, size_t len2)
576 return (len1 == len2 && memcmp(str1, str2, len1) == 0);
579 #define INTERNALIZER(t, f) \
580 { t, sizeof(t) - 1, f }
582 static const struct _prop_object_internalizer {
585 prop_object_internalizer_t poi_intern;
586 } _prop_object_internalizer_table[] = {
587 INTERNALIZER("array", _prop_array_internalize),
589 INTERNALIZER("true", _prop_bool_internalize),
590 INTERNALIZER("false", _prop_bool_internalize),
592 INTERNALIZER("data", _prop_data_internalize),
594 INTERNALIZER("dict", _prop_dictionary_internalize),
596 INTERNALIZER("integer", _prop_number_internalize),
598 INTERNALIZER("string", _prop_string_internalize),
606 * _prop_object_internalize_by_tag --
607 * Determine the object type from the tag in the context and
611 _prop_object_internalize_by_tag(struct _prop_object_internalize_context *ctx)
613 const struct _prop_object_internalizer *poi;
614 prop_object_t obj, parent_obj;
616 prop_object_internalizer_continue_t iter_func;
617 struct _prop_stack stack;
619 _prop_stack_init(&stack);
622 for (poi = _prop_object_internalizer_table;
623 poi->poi_tag != NULL; poi++) {
624 if (_prop_object_internalize_match(ctx->poic_tagname,
625 ctx->poic_tagname_len,
630 if ((poi == NULL) || (poi->poi_tag == NULL)) {
631 while (_prop_stack_pop(&stack, &obj, &iter, &data, NULL)) {
632 iter_func = (prop_object_internalizer_continue_t)iter;
633 (*iter_func)(&stack, &obj, ctx, data, NULL);
640 if (!(*poi->poi_intern)(&stack, &obj, ctx))
644 while (_prop_stack_pop(&stack, &parent_obj, &iter, &data, NULL)) {
645 iter_func = (prop_object_internalizer_continue_t)iter;
646 if (!(*iter_func)(&stack, &parent_obj, ctx, data, obj))
655 _prop_generic_internalize(const char *xml, const char *master_tag)
657 prop_object_t obj = NULL;
658 struct _prop_object_internalize_context *ctx;
660 ctx = _prop_object_internalize_context_alloc(xml);
664 /* We start with a <plist> tag. */
665 if (_prop_object_internalize_find_tag(ctx, "plist",
666 _PROP_TAG_TYPE_START) == false)
669 /* Plist elements cannot be empty. */
670 if (ctx->poic_is_empty_element)
674 * We don't understand any plist attributes, but Apple XML
675 * property lists often have a "version" attribute. If we
676 * see that one, we simply ignore it.
678 if (ctx->poic_tagattr != NULL &&
679 !_PROP_TAGATTR_MATCH(ctx, "version"))
682 /* Next we expect to see opening master_tag. */
683 if (_prop_object_internalize_find_tag(ctx, master_tag,
684 _PROP_TAG_TYPE_START) == false)
687 obj = _prop_object_internalize_by_tag(ctx);
692 * We've advanced past the closing master_tag.
693 * Now we want </plist>.
695 if (_prop_object_internalize_find_tag(ctx, "plist",
696 _PROP_TAG_TYPE_END) == false) {
697 prop_object_release(obj);
702 _prop_object_internalize_context_free(ctx);
707 * _prop_object_internalize_context_alloc --
708 * Allocate an internalize context.
710 struct _prop_object_internalize_context *
711 _prop_object_internalize_context_alloc(const char *xml)
713 struct _prop_object_internalize_context *ctx;
715 ctx = _PROP_MALLOC(sizeof(struct _prop_object_internalize_context),
720 ctx->poic_xml = ctx->poic_cp = xml;
723 * Skip any whitespace and XML preamble stuff that we don't
724 * know about / care about.
727 while (_PROP_ISSPACE(*xml))
729 if (_PROP_EOF(*xml) || *xml != '<')
732 #define MATCH(str) (memcmp(&xml[1], str, sizeof(str) - 1) == 0)
735 * Skip over the XML preamble that Apple XML property
736 * lists usually include at the top of the file.
738 if (MATCH("?xml ") ||
739 MATCH("!DOCTYPE plist")) {
740 while (*xml != '>' && !_PROP_EOF(*xml))
744 xml++; /* advance past the '>' */
749 ctx->poic_cp = xml + 4;
750 if (_prop_object_internalize_skip_comment(ctx) == false)
759 * We don't think we should skip it, so let's hope we can
768 _PROP_FREE(ctx, M_TEMP);
773 * _prop_object_internalize_context_free --
774 * Free an internalize context.
777 _prop_object_internalize_context_free(
778 struct _prop_object_internalize_context *ctx)
781 _PROP_FREE(ctx, M_TEMP);
784 #if !defined(_KERNEL) && !defined(_STANDALONE)
786 * _prop_object_externalize_file_dirname --
787 * dirname(3), basically. We have to roll our own because the
788 * system dirname(3) isn't reentrant.
791 _prop_object_externalize_file_dirname(const char *path, char *result)
797 * If `path' is a NULL pointer or points to an empty string,
800 if (path == NULL || *path == '\0')
803 /* String trailing slashes, if any. */
804 lastp = path + strlen(path) - 1;
805 while (lastp != path && *lastp == '/')
808 /* Terminate path at the last occurrence of '/'. */
811 /* Strip trailing slashes, if any. */
812 while (lastp != path && *lastp == '/')
815 /* ...and copy the result into the result buffer. */
816 len = (lastp - path) + 1 /* last char */;
817 if (len > (PATH_MAX - 1))
820 memcpy(result, path, len);
824 } while (--lastp >= path);
826 /* No /'s found, return ".". */
832 * _prop_object_externalize_write_file --
833 * Write an externalized dictionary to the specified file.
834 * The file is written atomically from the caller's perspective,
835 * and the mode set to 0666 modified by the caller's umask.
838 _prop_object_externalize_write_file(const char *fname, const char *xml,
841 char tname[PATH_MAX];
846 if (len > SSIZE_MAX) {
852 * Get the directory name where the file is to be written
853 * and create the temporary file.
855 _prop_object_externalize_file_dirname(fname, tname);
856 if (strlcat(tname, "/.plistXXXXXX", sizeof(tname)) >= sizeof(tname)) {
857 errno = ENAMETOOLONG;
860 if ((fd = mkstemp(tname)) == -1)
863 if (write(fd, xml, len) != (ssize_t)len)
870 (void)umask(myumask);
871 if (fchmod(fd, 0666 & ~myumask) == -1)
877 if (rename(tname, fname) == -1)
886 (void) unlink(tname);
892 * _prop_object_internalize_map_file --
893 * Map a file for the purpose of internalizing it.
895 struct _prop_object_internalize_mapped_file *
896 _prop_object_internalize_map_file(const char *fname)
899 struct _prop_object_internalize_mapped_file *mf;
900 size_t pgsize = (size_t)sysconf(_SC_PAGESIZE);
901 size_t pgmask = pgsize - 1;
902 bool need_guard = false;
905 mf = _PROP_MALLOC(sizeof(*mf), M_TEMP);
909 fd = open(fname, O_RDONLY, 0400);
911 _PROP_FREE(mf, M_TEMP);
915 if (fstat(fd, &sb) == -1) {
917 _PROP_FREE(mf, M_TEMP);
920 mf->poimf_mapsize = ((size_t)sb.st_size + pgmask) & ~pgmask;
921 if (mf->poimf_mapsize < (size_t)sb.st_size) {
923 _PROP_FREE(mf, M_TEMP);
928 * If the file length is an integral number of pages, then we
929 * need to map a guard page at the end in order to provide the
930 * necessary NUL-termination of the buffer.
932 if ((sb.st_size & pgmask) == 0)
935 mf->poimf_xml = mmap(NULL, need_guard ? mf->poimf_mapsize + pgsize
937 PROT_READ, MAP_FILE|MAP_SHARED, fd, (off_t)0);
939 if (mf->poimf_xml == MAP_FAILED) {
940 _PROP_FREE(mf, M_TEMP);
943 (void) madvise(mf->poimf_xml, mf->poimf_mapsize, MADV_SEQUENTIAL);
946 if (mmap(mf->poimf_xml + mf->poimf_mapsize,
948 MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1,
949 (off_t)0) == MAP_FAILED) {
950 (void) munmap(mf->poimf_xml, mf->poimf_mapsize);
951 _PROP_FREE(mf, M_TEMP);
954 mf->poimf_mapsize += pgsize;
961 * _prop_object_internalize_unmap_file --
962 * Unmap a file previously mapped for internalizing.
965 _prop_object_internalize_unmap_file(
966 struct _prop_object_internalize_mapped_file *mf)
969 (void) madvise(mf->poimf_xml, mf->poimf_mapsize, MADV_DONTNEED);
970 (void) munmap(mf->poimf_xml, mf->poimf_mapsize);
971 _PROP_FREE(mf, M_TEMP);
973 #endif /* !_KERNEL && !_STANDALONE */
976 * prop_object_retain --
977 * Increment the reference count on an object.
980 prop_object_retain(prop_object_t obj)
982 struct _prop_object *po = obj;
985 ncnt = atomic_inc_32_nv(&po->po_refcnt);
986 _PROP_ASSERT(ncnt != 0);
990 * prop_object_release_emergency
991 * A direct free with prop_object_release failed.
992 * Walk down the tree until a leaf is found and
993 * free that. Do not recurse to avoid stack overflows.
995 * This is a slow edge condition, but necessary to
996 * guarantee that an object can always be freed.
999 prop_object_release_emergency(prop_object_t obj)
1001 struct _prop_object *po;
1002 void (*unlock)(void);
1003 prop_object_t parent = NULL;
1010 if (po->po_type->pot_lock != NULL)
1011 po->po_type->pot_lock();
1013 /* Save pointerto unlock function */
1014 unlock = po->po_type->pot_unlock;
1016 /* Dance a bit to make sure we always get the non-racy ocnt */
1017 ocnt = atomic_dec_32_nv(&po->po_refcnt);
1019 _PROP_ASSERT(ocnt != 0);
1027 _PROP_ASSERT(po->po_type);
1028 if ((po->po_type->pot_free)(NULL, &obj) ==
1029 _PROP_OBJECT_FREE_DONE) {
1039 atomic_inc_32(&po->po_refcnt);
1041 _PROP_ASSERT(parent);
1042 /* One object was just freed. */
1044 (*po->po_type->pot_emergency_free)(parent);
1048 * prop_object_release --
1049 * Decrement the reference count on an object.
1051 * Free the object if we are releasing the final
1055 prop_object_release(prop_object_t obj)
1057 struct _prop_object *po;
1058 struct _prop_stack stack;
1059 void (*unlock)(void);
1063 _prop_stack_init(&stack);
1070 if (po->po_type->pot_lock != NULL)
1071 po->po_type->pot_lock();
1073 /* Save pointer to object unlock function */
1074 unlock = po->po_type->pot_unlock;
1076 ocnt = atomic_dec_32_nv(&po->po_refcnt);
1078 _PROP_ASSERT(ocnt != 0);
1087 ret = (po->po_type->pot_free)(&stack, &obj);
1092 if (ret == _PROP_OBJECT_FREE_DONE)
1095 atomic_inc_32(&po->po_refcnt);
1096 } while (ret == _PROP_OBJECT_FREE_RECURSE);
1097 if (ret == _PROP_OBJECT_FREE_FAILED)
1098 prop_object_release_emergency(obj);
1099 } while (_prop_stack_pop(&stack, &obj, NULL, NULL, NULL));
1103 * prop_object_type --
1104 * Return the type of an object.
1107 prop_object_type(prop_object_t obj)
1109 struct _prop_object *po = obj;
1112 return (PROP_TYPE_UNKNOWN);
1114 return (po->po_type->pot_type);
1118 * prop_object_equals --
1119 * Returns true if thw two objects are equivalent.
1122 prop_object_equals(prop_object_t obj1, prop_object_t obj2)
1124 return (prop_object_equals_with_error(obj1, obj2, NULL));
1128 prop_object_equals_with_error(prop_object_t obj1, prop_object_t obj2,
1131 struct _prop_object *po1;
1132 struct _prop_object *po2;
1133 void *stored_pointer1, *stored_pointer2;
1134 prop_object_t next_obj1, next_obj2;
1135 struct _prop_stack stack;
1136 _prop_object_equals_rv_t ret;
1138 _prop_stack_init(&stack);
1140 *error_flag = false;
1143 stored_pointer1 = NULL;
1144 stored_pointer2 = NULL;
1148 if (po1->po_type != po2->po_type)
1152 ret = (*po1->po_type->pot_equals)(obj1, obj2,
1153 &stored_pointer1, &stored_pointer2,
1154 &next_obj1, &next_obj2);
1155 if (ret == _PROP_OBJECT_EQUALS_FALSE)
1157 if (ret == _PROP_OBJECT_EQUALS_TRUE) {
1158 if (!_prop_stack_pop(&stack, &obj1, &obj2,
1159 &stored_pointer1, &stored_pointer2))
1161 goto continue_subtree;
1163 _PROP_ASSERT(ret == _PROP_OBJECT_EQUALS_RECURSE);
1165 if (!_prop_stack_push(&stack, obj1, obj2,
1166 stored_pointer1, stored_pointer2)) {
1176 while (_prop_stack_pop(&stack, &obj1, &obj2, NULL, NULL)) {
1178 (*po1->po_type->pot_equals_finish)(obj1, obj2);
1184 * prop_object_iterator_next --
1185 * Return the next item during an iteration.
1188 prop_object_iterator_next(prop_object_iterator_t pi)
1191 return ((*pi->pi_next_object)(pi));
1195 * prop_object_iterator_reset --
1196 * Reset the iterator to the first object so as to restart
1200 prop_object_iterator_reset(prop_object_iterator_t pi)
1203 (*pi->pi_reset)(pi);
1207 * prop_object_iterator_release --
1208 * Release the object iterator.
1211 prop_object_iterator_release(prop_object_iterator_t pi)
1214 prop_object_release(pi->pi_obj);
1215 _PROP_FREE(pi, M_TEMP);