Guest User

Untitled

a guest
Mar 1st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. dict_t * dict_new (void)
  2. {
  3. dict_t *dict = NULL;
  4.  
  5. dict = get_new_dict_full(1);
  6.  
  7. if (dict)
  8. dict_ref (dict);
  9.  
  10. return dict;
  11. }
  12.  
  13.  
  14. void dict_destroy (dict_t *this)
  15. {
  16. if (!this) {
  17. gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL,
  18. LG_MSG_INVALID_ARG, "dict is NULL");
  19. return;
  20. }
  21.  
  22. data_pair_t *pair = this->members_list;
  23. data_pair_t *prev = this->members_list;
  24.  
  25. LOCK_DESTROY (&this->lock);
  26.  
  27. while (prev) {
  28. pair = pair->next;
  29. data_unref (prev->value);
  30. GF_FREE (prev->key);
  31. if (prev != &this->free_pair) {
  32. mem_put (prev);
  33. }
  34. prev = pair;
  35. }
  36.  
  37. if (this->members != &this->members_internal) {
  38. mem_put (this->members);
  39. }
  40.  
  41. GF_FREE (this->extra_free);
  42. free (this->extra_stdfree);
  43.  
  44. if (!this->is_static)
  45. mem_put (this);
  46.  
  47. return;
  48. }
Add Comment
Please, Sign In to add comment