]> granicus.if.org Git - json-c/commitdiff
Apply gcc's "const" attribute to the json_c_object_sizeof() function as an optimizer...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Tue, 12 Dec 2017 23:26:51 +0000 (18:26 -0500)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Tue, 12 Dec 2017 23:26:51 +0000 (18:26 -0500)
json_object.c
json_object.h

index f12d8f08d8ab3f041381d19a628c19af0ac6d25f..042477a71b8cc3963eb792a6c5c74f953532d5ff 100644 (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);
 }
index 6a2751d228b96828e8279a729a2081a6c80a8074..758efa6f1d28af851c02fc447bb5db341eb39a69 100644 (file)
 #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
  *