# HG changeset patch
# User ZyX <[email protected]>
# Date 1369716038 -14400
# Node ID 18fe917c66b253cdd7a8d6e55556738ac1b5e3dc
# Parent 6f5c6a9e88bfef3f0bbbbb92e69bc4efaa88452d
Purge out DICTKEY_CHECK_EMPTY macros
Where it used to be used it has possible memory leak problem
diff -r 6f5c6a9e88bf -r 18fe917c66b2 src/if_py_both.h
--- a/src/if_py_both.h Tue May 28 08:29:42 2013 +0400
+++ b/src/if_py_both.h Tue May 28 08:40:38 2013 +0400
@@ -32,15 +32,8 @@
#define DICTKEY_DECL \
PyObject *dictkey_todecref = NULL;
-#define DICTKEY_CHECK_EMPTY(err) \
- if (*key == NUL) \
- { \
- PyErr_SetString(PyExc_ValueError, _("empty keys are not allowed")); \
- return err; \
- }
-#define DICTKEY_SET_KEY (key = StringToChars(keyObject, &dictkey_todecref))
#define DICTKEY_GET(err, decref) \
- if (!DICTKEY_SET_KEY) \
+ if (!(key = StringToChars(keyObject, &dictkey_todecref))) \
{ \
if (decref) \
{ \
@@ -50,7 +43,11 @@
} \
if (decref && !dictkey_todecref) \
dictkey_todecref = keyObject; \
- DICTKEY_CHECK_EMPTY(err)
+ if (*key == NUL) \
+ { \
+ PyErr_SetString(PyExc_ValueError, _("empty keys are not allowed")); \
+ return err; \
+ }
#define DICTKEY_UNREF \
Py_XDECREF(dictkey_todecref);
@@ -4552,7 +4549,7 @@
while (PyDict_Next(obj, &iter, &keyObject, &valObject))
{
- DICTKEY_DECL
+ PyObject *todecref = NULL;
if (keyObject == NULL || valObject == NULL)
{
@@ -4560,16 +4557,21 @@
return -1;
}
- if (!DICTKEY_SET_KEY)
+ if (!(key = StringToChars(keyObject, &todecref)))
{
dict_unref(dict);
return -1;
}
- DICTKEY_CHECK_EMPTY(-1)
+ if (*key == NUL)
+ {
+ dict_unref(dict);
+ Py_XDECREF(todecref);
+ return -1;
+ }
di = dictitem_alloc(key);
- DICTKEY_UNREF
+ Py_XDECREF(todecref);
if (di == NULL)
{
@@ -4633,31 +4635,37 @@
while ((keyObject = PyIter_Next(iterator)))
{
- DICTKEY_DECL
-
- if (!DICTKEY_SET_KEY)
+ PyObject *todecref;
+
+ if (!(key = StringToChars(keyObject, &todecref)))
{
+ Py_DECREF(keyObject);
Py_DECREF(iterator);
dict_unref(dict);
- DICTKEY_UNREF
return -1;
}
- DICTKEY_CHECK_EMPTY(-1)
+ if (*key == NUL)
+ {
+ Py_DECREF(keyObject);
+ Py_DECREF(iterator);
+ Py_XDECREF(todecref);
+ dict_unref(dict);
+ return -1;
+ }
if (!(valObject = PyObject_GetItem(obj, keyObject)))
{
Py_DECREF(keyObject);
Py_DECREF(iterator);
+ Py_XDECREF(todecref);
dict_unref(dict);
- DICTKEY_UNREF
return -1;
}
di = dictitem_alloc(key);
- DICTKEY_UNREF
-
Py_DECREF(keyObject);
+ Py_XDECREF(todecref);
if (di == NULL)
{
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
*** /tmp/extdiff.ooXfbz/vim.6f5c6a9e88bf/src/if_py_both.h 2013-05-28 08:41:28.771416407 +0400
--- vim.18fe917c66b2/src/if_py_both.h 2013-05-28 08:41:28.778416356 +0400
***************
*** 32,46 ****
#define DICTKEY_DECL \
PyObject *dictkey_todecref = NULL;
- #define DICTKEY_CHECK_EMPTY(err) \
- if (*key == NUL) \
- { \
- PyErr_SetString(PyExc_ValueError, _("empty keys are not allowed")); \
- return err; \
- }
- #define DICTKEY_SET_KEY (key = StringToChars(keyObject, &dictkey_todecref))
#define DICTKEY_GET(err, decref) \
! if (!DICTKEY_SET_KEY) \
{ \
if (decref) \
{ \
--- 32,39 ----
#define DICTKEY_DECL \
PyObject *dictkey_todecref = NULL;
#define DICTKEY_GET(err, decref) \
! if (!(key = StringToChars(keyObject, &dictkey_todecref))) \
{ \
if (decref) \
{ \
***************
*** 50,56 ****
} \
if (decref && !dictkey_todecref) \
dictkey_todecref = keyObject; \
! DICTKEY_CHECK_EMPTY(err)
#define DICTKEY_UNREF \
Py_XDECREF(dictkey_todecref);
--- 43,53 ----
} \
if (decref && !dictkey_todecref) \
dictkey_todecref = keyObject; \
! if (*key == NUL) \
! { \
! PyErr_SetString(PyExc_ValueError, _("empty keys are not allowed")); \
! return err; \
! }
#define DICTKEY_UNREF \
Py_XDECREF(dictkey_todecref);
***************
*** 4552,4558 ****
while (PyDict_Next(obj, &iter, &keyObject, &valObject))
{
! DICTKEY_DECL
if (keyObject == NULL || valObject == NULL)
{
--- 4549,4555 ----
while (PyDict_Next(obj, &iter, &keyObject, &valObject))
{
! PyObject *todecref = NULL;
if (keyObject == NULL || valObject == NULL)
{
***************
*** 4560,4575 ****
return -1;
}
! if (!DICTKEY_SET_KEY)
{
dict_unref(dict);
return -1;
}
- DICTKEY_CHECK_EMPTY(-1)
di = dictitem_alloc(key);
! DICTKEY_UNREF
if (di == NULL)
{
--- 4557,4577 ----
return -1;
}
! if (!(key = StringToChars(keyObject, &todecref)))
! {
! dict_unref(dict);
! return -1;
! }
! if (*key == NUL)
{
dict_unref(dict);
+ Py_XDECREF(todecref);
return -1;
}
di = dictitem_alloc(key);
! Py_XDECREF(todecref);
if (di == NULL)
{
***************
*** 4633,4663 ****
while ((keyObject = PyIter_Next(iterator)))
{
! DICTKEY_DECL
! if (!DICTKEY_SET_KEY)
{
Py_DECREF(iterator);
dict_unref(dict);
- DICTKEY_UNREF
return -1;
}
! DICTKEY_CHECK_EMPTY(-1)
if (!(valObject = PyObject_GetItem(obj, keyObject)))
{
Py_DECREF(keyObject);
Py_DECREF(iterator);
dict_unref(dict);
- DICTKEY_UNREF
return -1;
}
di = dictitem_alloc(key);
- DICTKEY_UNREF
-
Py_DECREF(keyObject);
if (di == NULL)
{
--- 4635,4671 ----
while ((keyObject = PyIter_Next(iterator)))
{
! PyObject *todecref;
! if (!(key = StringToChars(keyObject, &todecref)))
{
+ Py_DECREF(keyObject);
Py_DECREF(iterator);
dict_unref(dict);
return -1;
}
! if (*key == NUL)
! {
! Py_DECREF(keyObject);
! Py_DECREF(iterator);
! Py_XDECREF(todecref);
! dict_unref(dict);
! return -1;
! }
if (!(valObject = PyObject_GetItem(obj, keyObject)))
{
Py_DECREF(keyObject);
Py_DECREF(iterator);
+ Py_XDECREF(todecref);
dict_unref(dict);
return -1;
}
di = dictitem_alloc(key);
Py_DECREF(keyObject);
+ Py_XDECREF(todecref);
if (di == NULL)
{