aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libucl/ucl.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-25 12:13:09 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-25 12:13:09 +0100
commit24d852704f94f74caf96ddb512ae2fc7e6129c4b (patch)
treed7d10174181db7bed5a786dc8f543ff3d6817851 /contrib/libucl/ucl.h
parent19026c7116f1e394049d063d50147f8a2458f351 (diff)
downloadrspamd-24d852704f94f74caf96ddb512ae2fc7e6129c4b.tar.gz
rspamd-24d852704f94f74caf96ddb512ae2fc7e6129c4b.zip
[Minor] Merge OOM fixes from libucl
Diffstat (limited to 'contrib/libucl/ucl.h')
-rw-r--r--contrib/libucl/ucl.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/contrib/libucl/ucl.h b/contrib/libucl/ucl.h
index 482812d46..01542d3c7 100644
--- a/contrib/libucl/ucl.h
+++ b/contrib/libucl/ucl.h
@@ -469,8 +469,9 @@ UCL_EXTERN bool ucl_object_insert_key_merged (ucl_object_t *top, ucl_object_t *e
* Reserve space in ucl array or object for `elt` elements
* @param obj object to reserve
* @param reserved size to reserve in an object
+ * @return 0 on success, -1 on failure (i.e. ENOMEM)
*/
-UCL_EXTERN void ucl_object_reserve (ucl_object_t *obj, size_t reserved);
+UCL_EXTERN bool ucl_object_reserve (ucl_object_t *obj, size_t reserved);
/**
* Append an element to the end of array object
@@ -825,11 +826,14 @@ typedef void* ucl_object_iter_t;
* @param iter opaque iterator, must be set to NULL on the first call:
* ucl_object_iter_t it = NULL;
* while ((cur = ucl_iterate_object (obj, &it)) != NULL) ...
+ * @param ep pointer record exception (such as ENOMEM), could be NULL
* @return the next object or NULL
*/
-UCL_EXTERN const ucl_object_t* ucl_object_iterate (const ucl_object_t *obj,
- ucl_object_iter_t *iter, bool expand_values);
+UCL_EXTERN const ucl_object_t* ucl_object_iterate_with_error (const ucl_object_t *obj,
+ ucl_object_iter_t *iter, bool expand_values, int *ep);
+
#define ucl_iterate_object ucl_object_iterate
+#define ucl_object_iterate(ob, it, ev) ucl_object_iterate_with_error((ob), (it), (ev), NULL)
/**
* Create new safe iterator for the specified object
@@ -839,6 +843,15 @@ UCL_EXTERN const ucl_object_t* ucl_object_iterate (const ucl_object_t *obj,
UCL_EXTERN ucl_object_iter_t ucl_object_iterate_new (const ucl_object_t *obj)
UCL_WARN_UNUSED_RESULT;
/**
+ * Check safe iterator object after performing some operations on it
+ * (such as ucl_object_iterate_safe()) to see if operation has encountered
+ * fatal exception while performing that operation (e.g. ENOMEM).
+ * @param iter opaque iterator
+ * @return true if exception has occured, false otherwise
+ */
+UCL_EXTERN bool ucl_object_iter_chk_excpn(ucl_object_iter_t *it);
+
+/**
* Reset initialized iterator to a new object
* @param obj new object to iterate
* @return modified iterator object
@@ -951,8 +964,9 @@ UCL_EXTERN int ucl_parser_get_default_priority (struct ucl_parser *parser);
* @param macro macro name (without leading dot)
* @param handler handler (it is called immediately after macro is parsed)
* @param ud opaque user data for a handler
+ * @return true on success, false on failure (i.e. ENOMEM)
*/
-UCL_EXTERN void ucl_parser_register_macro (struct ucl_parser *parser,
+UCL_EXTERN bool ucl_parser_register_macro (struct ucl_parser *parser,
const char *macro,
ucl_macro_handler handler, void* ud);
@@ -962,8 +976,9 @@ UCL_EXTERN void ucl_parser_register_macro (struct ucl_parser *parser,
* @param macro macro name (without leading dot)
* @param handler handler (it is called immediately after macro is parsed)
* @param ud opaque user data for a handler
+ * @return true on success, false on failure (i.e. ENOMEM)
*/
-UCL_EXTERN void ucl_parser_register_context_macro (struct ucl_parser *parser,
+UCL_EXTERN bool ucl_parser_register_context_macro (struct ucl_parser *parser,
const char *macro,
ucl_context_macro_handler handler,
void* ud);