Merge branch '1.3'
Conflicts: doc/apiref.rst src/jansson_private.h
This commit is contained in:
@@ -17,4 +17,7 @@ libjansson_la_LDFLAGS = \
|
||||
-export-symbols-regex '^json_' \
|
||||
-version-info 3:0:3
|
||||
|
||||
if GCC
|
||||
# These flags are gcc specific
|
||||
AM_CFLAGS = -Wall -Wextra -Werror
|
||||
endif
|
||||
|
||||
@@ -113,7 +113,7 @@ int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
|
||||
return json_object_set_new_nocheck(object, key, json_incref(value));
|
||||
}
|
||||
|
||||
static inline
|
||||
static JSON_INLINE
|
||||
int json_object_iter_set(json_t *object, void *iter, json_t *value)
|
||||
{
|
||||
return json_object_iter_set_new(object, iter, json_incref(value));
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
#ifndef JANSSON_PRIVATE_H
|
||||
#define JANSSON_PRIVATE_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "jansson.h"
|
||||
#include "hashtable.h"
|
||||
|
||||
#define container_of(ptr_, type_, member_) \
|
||||
((type_ *)((char *)ptr_ - (size_t)&((type_ *)0)->member_))
|
||||
((type_ *)((char *)ptr_ - offsetof(type_, member_)))
|
||||
|
||||
typedef struct {
|
||||
json_t json;
|
||||
@@ -52,7 +53,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
size_t serial;
|
||||
char key[];
|
||||
char key[1];
|
||||
} object_key_t;
|
||||
|
||||
const object_key_t *jsonp_object_iter_fullkey(void *iter);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -124,9 +125,11 @@ int json_object_set_new_nocheck(json_t *json, const char *key, json_t *value)
|
||||
}
|
||||
object = json_to_object(json);
|
||||
|
||||
k = malloc(sizeof(object_key_t) + strlen(key) + 1);
|
||||
if(!k)
|
||||
return -1;
|
||||
/* offsetof(...) returns the size of object_key_t without the
|
||||
last, flexible member. This way, the correct amount is
|
||||
allocated. */
|
||||
k = malloc(offsetof(object_key_t, key) +
|
||||
strlen(key) + 1); if(!k) return -1;
|
||||
|
||||
k->serial = object->serial++;
|
||||
strcpy(k->key, key);
|
||||
|
||||
Reference in New Issue
Block a user