Browse Source

Apply gcc's "const" attribute to the json_c_object_sizeof() function as an optimizer hint. Also, rename that function from json_object_sizeof().

tags/json-c-0.13.1-20180305
Eric Haszlakiewicz Björn Esser 7 years ago
parent
commit
8baf437817
No known key found for this signature in database GPG Key ID: F52E98007594C21D
2 changed files with 8 additions and 2 deletions
  1. +1
    -1
      json_object.c
  2. +7
    -1
      json_object.h

+ 1
- 1
json_object.c View File

@@ -509,7 +509,7 @@ int json_object_object_length(const struct json_object *jso)
return lh_table_length(jso->o.c_object);
}

size_t json_object_sizeof(void)
size_t json_c_object_sizeof(void)
{
return sizeof(struct json_object);
}


+ 7
- 1
json_object.h View File

@@ -27,6 +27,12 @@
#define THIS_FUNCTION_IS_DEPRECATED(func) func
#endif

#ifdef __GNUC__
#define JSON_C_CONST_FUNCTION(func) func __attribute__((const))
#else
#define CONST_FUNCTION(func) func
#endif

#if defined(_MSC_VER)
#define JSON_EXPORT __declspec(dllexport)
#else
@@ -395,7 +401,7 @@ JSON_EXPORT int json_object_object_length(const struct json_object* obj);
/** Get the sizeof (struct json_object).
* @returns a size_t with the sizeof (struct json_object)
*/
JSON_EXPORT size_t json_object_sizeof(void);
JSON_C_CONST_FUNCTION(JSON_EXPORT size_t json_c_object_sizeof(void));

/** Add an object field to a json_object of type json_type_object
*


Loading…
Cancel
Save