comparison src/if_py_both.h @ 3824:2bf8c00741f7 v7.3.670

updated for version 7.3.670 Problem: Python: memory leaks when there are exceptions. Solution: Add DICTKEY_UNREF in the right places. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Fri, 21 Sep 2012 13:43:14 +0200
parents 5e909c379a1e
children 530f5a903031
comparison
equal deleted inserted replaced
3823:1280c67eb433 3824:2bf8c00741f7
797 797
798 DICTKEY_GET_NOTEMPTY(NULL) 798 DICTKEY_GET_NOTEMPTY(NULL)
799 799
800 di = dict_find(((DictionaryObject *) (self))->dict, key, -1); 800 di = dict_find(((DictionaryObject *) (self))->dict, key, -1);
801 801
802 DICTKEY_UNREF
803
802 if (di == NULL) 804 if (di == NULL)
803 { 805 {
804 PyErr_SetString(PyExc_IndexError, _("no such key in dictionary")); 806 PyErr_SetString(PyExc_IndexError, _("no such key in dictionary"));
805 return NULL; 807 return NULL;
806 } 808 }
807
808 DICTKEY_UNREF
809 809
810 return ConvertToPyObject(&di->di_tv); 810 return ConvertToPyObject(&di->di_tv);
811 } 811 }
812 812
813 static PyInt 813 static PyInt
833 { 833 {
834 hashitem_T *hi; 834 hashitem_T *hi;
835 835
836 if (di == NULL) 836 if (di == NULL)
837 { 837 {
838 DICTKEY_UNREF
838 PyErr_SetString(PyExc_IndexError, _("no such key in dictionary")); 839 PyErr_SetString(PyExc_IndexError, _("no such key in dictionary"));
839 return -1; 840 return -1;
840 } 841 }
841 hi = hash_find(&d->dv_hashtab, di->di_key); 842 hi = hash_find(&d->dv_hashtab, di->di_key);
842 hash_remove(&d->dv_hashtab, hi); 843 hash_remove(&d->dv_hashtab, hi);
857 } 858 }
858 di->di_tv.v_lock = 0; 859 di->di_tv.v_lock = 0;
859 860
860 if (dict_add(d, di) == FAIL) 861 if (dict_add(d, di) == FAIL)
861 { 862 {
863 DICTKEY_UNREF
862 vim_free(di); 864 vim_free(di);
863 PyErr_SetVim(_("failed to add key to dictionary")); 865 PyErr_SetVim(_("failed to add key to dictionary"));
864 return -1; 866 return -1;
865 } 867 }
866 } 868 }