Rebase to 2.8
This commit is contained in:
parent
41ee69bea7
commit
dabb51c7ce
88
jansson-2.8-json_auto_t.patch
Normal file
88
jansson-2.8-json_auto_t.patch
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
From 63b9fd055248bcd427fd455ce9623431885b235e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Nathaniel McCallum <npmccallum@redhat.com>
|
||||||
|
Date: Tue, 30 Aug 2016 16:12:22 -0400
|
||||||
|
Subject: [PATCH] Add support for the cleanup attribute in GCC/Clang
|
||||||
|
|
||||||
|
The new json_auto_t macro allows easy declaration of json_t types that
|
||||||
|
automatically decrement at the end of their scope.
|
||||||
|
---
|
||||||
|
doc/apiref.rst | 18 ++++++++++++++++++
|
||||||
|
src/jansson.h | 13 +++++++++++++
|
||||||
|
test/suites/api/test_simple.c | 13 +++++++++++++
|
||||||
|
3 files changed, 44 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/doc/apiref.rst b/doc/apiref.rst
|
||||||
|
index 0ab2348..2a090e4 100644
|
||||||
|
--- a/doc/apiref.rst
|
||||||
|
+++ b/doc/apiref.rst
|
||||||
|
@@ -253,6 +253,24 @@ other. Moreover, trying to encode the values with any of the encoding
|
||||||
|
functions will fail. The encoder detects circular references and
|
||||||
|
returns an error status.
|
||||||
|
|
||||||
|
+Scope Dereferencing
|
||||||
|
+-------------------
|
||||||
|
+
|
||||||
|
+It is possible to use the ``json_auto_t`` type to automatically
|
||||||
|
+dereference a value at the end of a scope. For example::
|
||||||
|
+
|
||||||
|
+ void function(void) {
|
||||||
|
+ json_auto_t *value = NULL;
|
||||||
|
+ value = json_string("foo");
|
||||||
|
+ /* json_decref(value) is automatically called. */
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+This feature is only available on GCC and Clang. So if your project
|
||||||
|
+has a portability requirement for other compilers, you should avoid
|
||||||
|
+this feature.
|
||||||
|
+
|
||||||
|
+Additionally, as always, care should be taken when passing values to
|
||||||
|
+functions that steal references.
|
||||||
|
|
||||||
|
True, False and Null
|
||||||
|
====================
|
||||||
|
diff --git a/src/jansson.h b/src/jansson.h
|
||||||
|
index 17a6e7a..b1a040a 100644
|
||||||
|
--- a/src/jansson.h
|
||||||
|
+++ b/src/jansson.h
|
||||||
|
@@ -112,6 +112,19 @@ void json_decref(json_t *json)
|
||||||
|
json_delete(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#if defined(__GNUC__) || defined(__clang__)
|
||||||
|
+static JSON_INLINE
|
||||||
|
+void json_decrefp(json_t **json)
|
||||||
|
+{
|
||||||
|
+ if(json) {
|
||||||
|
+ json_decref(*json);
|
||||||
|
+ *json = NULL;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#define json_auto_t json_t __attribute__((cleanup(json_decrefp)))
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
|
||||||
|
/* error reporting */
|
||||||
|
|
||||||
|
diff --git a/test/suites/api/test_simple.c b/test/suites/api/test_simple.c
|
||||||
|
index 8b56954..e461561 100644
|
||||||
|
--- a/test/suites/api/test_simple.c
|
||||||
|
+++ b/test/suites/api/test_simple.c
|
||||||
|
@@ -224,4 +224,17 @@ static void run_tests()
|
||||||
|
json_incref(value);
|
||||||
|
if(value->refcount != (size_t)-1)
|
||||||
|
fail("refcounting null works incorrectly");
|
||||||
|
+
|
||||||
|
+#ifdef json_auto_t
|
||||||
|
+ value = json_string("foo");
|
||||||
|
+ {
|
||||||
|
+ json_auto_t *test = json_incref(value);
|
||||||
|
+ /* Use test so GCC doesn't complain it is unused. */
|
||||||
|
+ if(!json_is_string(test))
|
||||||
|
+ fail("value type check failed");
|
||||||
|
+ }
|
||||||
|
+ if(value->refcount != 1)
|
||||||
|
+ fail("automatic decrement failed");
|
||||||
|
+ json_decref(value);
|
||||||
|
+#endif
|
||||||
|
}
|
12
jansson.spec
12
jansson.spec
@ -1,14 +1,16 @@
|
|||||||
Name: jansson
|
Name: jansson
|
||||||
Version: 2.7
|
Version: 2.8
|
||||||
Release: 3%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: C library for encoding, decoding and manipulating JSON data
|
Summary: C library for encoding, decoding and manipulating JSON data
|
||||||
|
|
||||||
Group: System Environment/Libraries
|
Group: System Environment/Libraries
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: http://www.digip.org/jansson/
|
URL: http://www.digip.org/jansson/
|
||||||
Source0: http://www.digip.org/jansson/releases/jansson-%{version}.tar.bz2
|
Source0: http://www.digip.org/jansson/releases/jansson-%{version}.tar.bz2
|
||||||
|
Patch0: jansson-2.8-json_auto_t.patch
|
||||||
|
|
||||||
BuildRequires: python-sphinx
|
BuildRequires: python-sphinx
|
||||||
|
BuildRequires: git
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Small library for parsing and writing JSON documents.
|
Small library for parsing and writing JSON documents.
|
||||||
@ -29,7 +31,7 @@ BuildArch: noarch
|
|||||||
Development documentation for jansson.
|
Development documentation for jansson.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%autosetup -S git
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%configure --disable-static
|
%configure --disable-static
|
||||||
@ -60,6 +62,10 @@ rm "$RPM_BUILD_ROOT%{_libdir}"/*.la
|
|||||||
%doc doc/_build/html/*
|
%doc doc/_build/html/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Sep 16 2016 Nathaniel McCallum <npmccallum@redhat.com> - 2.8-1
|
||||||
|
- Update to Jansson 2.8
|
||||||
|
- Add json_auto_t patch
|
||||||
|
|
||||||
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.7-3
|
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.7-3
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user