Lines Matching refs:pd
356 prop_dictionary_t pd = *obj;
360 _PROP_ASSERT(pd->pd_count <= pd->pd_capacity);
361 _PROP_ASSERT((pd->pd_capacity == 0 && pd->pd_array == NULL) ||
362 (pd->pd_capacity != 0 && pd->pd_array != NULL));
365 if (pd->pd_count == 0) {
366 if (pd->pd_array != NULL)
367 _PROP_FREE(pd->pd_array, M_PROP_DICT);
369 _PROP_RWLOCK_DESTROY(pd->pd_rwlock);
371 _PROP_POOL_PUT(_prop_dictionary_pool, pd);
376 po = pd->pd_array[pd->pd_count - 1].pde_objref;
389 if (!_prop_stack_push(stack, pd, NULL, NULL, NULL)) {
394 --pd->pd_count;
395 pdk = pd->pd_array[pd->pd_count].pde_key;
423 prop_dictionary_t pd = obj;
426 _PROP_ASSERT(pd->pd_count != 0);
427 --pd->pd_count;
429 pdk = pd->pd_array[pd->pd_count].pde_key;
470 prop_dictionary_t pd = v;
481 _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
483 if (pd->pd_count == 0) {
484 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
494 pdi = _prop_dictionary_iterator_locked(pd);
503 po = _prop_dictionary_get_keysym(pd, pdk, true);
507 pdi->pdi_index < pd->pd_count ?
527 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
597 prop_dictionary_t pd;
607 pd = _PROP_POOL_GET(_prop_dictionary_pool);
608 if (pd != NULL) {
609 _prop_object_init(&pd->pd_obj, &_prop_object_type_dictionary);
611 _PROP_RWLOCK_INIT(pd->pd_rwlock);
612 pd->pd_array = array;
613 pd->pd_capacity = capacity;
614 pd->pd_count = 0;
615 pd->pd_flags = 0;
617 pd->pd_version = 0;
621 return (pd);
625 _prop_dictionary_expand(prop_dictionary_t pd, unsigned int capacity)
633 oarray = pd->pd_array;
639 memcpy(array, oarray, pd->pd_capacity * sizeof(*array));
640 pd->pd_array = array;
641 pd->pd_capacity = capacity;
653 prop_dictionary_t pd = pdi->pdi_base.pi_obj;
656 _PROP_ASSERT(prop_object_is_dictionary(pd));
658 if (pd->pd_version != pdi->pdi_base.pi_version)
661 _PROP_ASSERT(pdi->pdi_index <= pd->pd_count);
663 if (pdi->pdi_index == pd->pd_count)
666 pdk = pd->pd_array[pdi->pdi_index].pde_key;
677 prop_dictionary_t pd _PROP_ARG_UNUSED = pdi->pdi_base.pi_obj;
680 _PROP_ASSERT(prop_object_is_dictionary(pd));
682 _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
684 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
692 prop_dictionary_t pd = pdi->pdi_base.pi_obj;
694 _PROP_ASSERT(prop_object_is_dictionary(pd));
697 pdi->pdi_base.pi_version = pd->pd_version;
704 prop_dictionary_t pd _PROP_ARG_UNUSED = pdi->pdi_base.pi_obj;
706 _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
708 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
743 prop_dictionary_t pd;
753 pd = _prop_dictionary_alloc(opd->pd_count);
754 if (pd != NULL) {
762 pd->pd_array[idx].pde_key = pdk;
763 pd->pd_array[idx].pde_objref = po;
765 pd->pd_count = opd->pd_count;
766 pd->pd_flags = opd->pd_flags;
769 return (pd);
780 prop_dictionary_t pd;
785 pd = prop_dictionary_copy(opd);
786 if (pd != NULL)
787 pd->pd_flags &= ~PD_F_IMMUTABLE;
789 return (pd);
797 prop_dictionary_make_immutable(prop_dictionary_t pd)
800 _PROP_RWLOCK_WRLOCK(pd->pd_rwlock);
801 if (prop_dictionary_is_immutable(pd) == false)
802 pd->pd_flags |= PD_F_IMMUTABLE;
803 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
811 prop_dictionary_count(prop_dictionary_t pd)
815 if (! prop_object_is_dictionary(pd))
818 _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
819 rv = pd->pd_count;
820 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
832 prop_dictionary_ensure_capacity(prop_dictionary_t pd, unsigned int capacity)
836 if (! prop_object_is_dictionary(pd))
839 _PROP_RWLOCK_WRLOCK(pd->pd_rwlock);
840 if (capacity > pd->pd_capacity)
841 rv = _prop_dictionary_expand(pd, capacity);
844 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
849 _prop_dictionary_iterator_locked(prop_dictionary_t pd)
853 if (! prop_object_is_dictionary(pd))
861 prop_object_retain(pd);
862 pdi->pdi_base.pi_obj = pd;
874 prop_dictionary_iterator(prop_dictionary_t pd)
878 _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
879 pdi = _prop_dictionary_iterator_locked(pd);
880 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
890 prop_dictionary_all_keys(prop_dictionary_t pd)
896 if (! prop_object_is_dictionary(pd))
900 array = prop_array_create_with_capacity(pd->pd_count);
902 _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
904 for (idx = 0; idx < pd->pd_count; idx++) {
905 rv = prop_array_add(array, pd->pd_array[idx].pde_key);
910 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
920 _prop_dict_lookup(prop_dictionary_t pd, const char *key,
931 for (idx = 0, base = 0, distance = pd->pd_count; distance != 0;
934 pde = &pd->pd_array[idx];
955 _prop_dictionary_get(prop_dictionary_t pd, const char *key, bool locked)
960 if (! prop_object_is_dictionary(pd))
964 _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
966 pde = _prop_dict_lookup(pd, key, NULL);
972 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
981 prop_dictionary_get(prop_dictionary_t pd, const char *key)
985 if (! prop_object_is_dictionary(pd))
988 _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
989 po = _prop_dictionary_get(pd, key, true);
990 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
995 _prop_dictionary_get_keysym(prop_dictionary_t pd, prop_dictionary_keysym_t pdk,
999 if (! (prop_object_is_dictionary(pd) &&
1003 return (_prop_dictionary_get(pd, pdk->pdk_key, locked));
1011 prop_dictionary_get_keysym(prop_dictionary_t pd, prop_dictionary_keysym_t pdk)
1014 return (_prop_dictionary_get_keysym(pd, pdk, false));
1023 prop_dictionary_set(prop_dictionary_t pd, const char *key, prop_object_t po)
1030 if (! prop_object_is_dictionary(pd))
1033 _PROP_ASSERT(pd->pd_count <= pd->pd_capacity);
1035 if (prop_dictionary_is_immutable(pd))
1038 _PROP_RWLOCK_WRLOCK(pd->pd_rwlock);
1040 pde = _prop_dict_lookup(pd, key, &idx);
1054 if (pd->pd_count == pd->pd_capacity &&
1055 _prop_dictionary_expand(pd,
1056 pd->pd_capacity + EXPAND_STEP) == false) {
1064 if (pd->pd_count == 0) {
1065 pd->pd_array[0].pde_key = pdk;
1066 pd->pd_array[0].pde_objref = po;
1067 pd->pd_count++;
1068 pd->pd_version++;
1073 pde = &pd->pd_array[idx];
1086 memmove(&pd->pd_array[1], &pd->pd_array[0],
1087 pd->pd_count * sizeof(*pde));
1088 pd->pd_array[0].pde_key = pdk;
1089 pd->pd_array[0].pde_objref = po;
1090 pd->pd_count++;
1091 pd->pd_version++;
1098 memmove(&pd->pd_array[idx + 2], &pd->pd_array[idx + 1],
1099 (pd->pd_count - (idx + 1)) * sizeof(*pde));
1100 pd->pd_array[idx + 1].pde_key = pdk;
1101 pd->pd_array[idx + 1].pde_objref = po;
1102 pd->pd_count++;
1104 pd->pd_version++;
1109 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
1119 prop_dictionary_set_keysym(prop_dictionary_t pd, prop_dictionary_keysym_t pdk,
1123 if (! (prop_object_is_dictionary(pd) &&
1127 return (prop_dictionary_set(pd, pdk->pdk_key, po));
1131 _prop_dictionary_remove(prop_dictionary_t pd, struct _prop_dict_entry *pde,
1141 _PROP_ASSERT(pd->pd_count != 0);
1142 _PROP_ASSERT(idx < pd->pd_count);
1143 _PROP_ASSERT(pde == &pd->pd_array[idx]);
1146 memmove(&pd->pd_array[idx - 1], &pd->pd_array[idx],
1147 (pd->pd_count - idx) * sizeof(*pde));
1148 pd->pd_count--;
1149 pd->pd_version++;
1163 prop_dictionary_remove(prop_dictionary_t pd, const char *key)
1168 if (! prop_object_is_dictionary(pd))
1171 _PROP_RWLOCK_WRLOCK(pd->pd_rwlock);
1174 if (prop_dictionary_is_immutable(pd))
1177 pde = _prop_dict_lookup(pd, key, &idx);
1182 _prop_dictionary_remove(pd, pde, idx);
1184 _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
1193 prop_dictionary_remove_keysym(prop_dictionary_t pd,
1197 if (! (prop_object_is_dictionary(pd) &&
1201 prop_dictionary_remove(pd, pdk->pdk_key);
1267 prop_dictionary_externalize(prop_dictionary_t pd)
1269 return _prop_object_externalize(&pd->pd_obj, PROP_FORMAT_XML);