From 5f3f35a2c29bd91c52d0470ba5a6beed8b6e4bed Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Fri, 24 Feb 2012 04:25:08 +0000 Subject: [PATCH] Mark getnextarg function as returning a borrowed reference --- psycopg/bytes_format.c | 1 + psycopg/config.h | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/psycopg/bytes_format.c b/psycopg/bytes_format.c index 1e729e49..b22422b0 100644 --- a/psycopg/bytes_format.c +++ b/psycopg/bytes_format.c @@ -86,6 +86,7 @@ /* Helpers for formatstring */ +CPYCHECKER_RETURNS_BORROWED_REF Py_LOCAL_INLINE(PyObject *) getnextarg(PyObject *args, Py_ssize_t arglen, Py_ssize_t *p_argidx) { diff --git a/psycopg/config.h b/psycopg/config.h index 2112043b..321587a0 100644 --- a/psycopg/config.h +++ b/psycopg/config.h @@ -160,4 +160,12 @@ static double round(double num) #define isinf(x) (!finite((x)) && (x)==(x)) #endif +/* decorator for the gcc cpychecker plugin */ +#if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE) + #define CPYCHECKER_RETURNS_BORROWED_REF \ + __attribute__((cpychecker_returns_borrowed_ref)) +#else + #define CPYCHECKER_RETURNS_BORROWED_REF +#endif + #endif /* !defined(PSYCOPG_CONFIG_H) */