2011-12-07 Mike Blumenkrantz (discomfitor/zmike)
* eina_log*level_check() functions now return the correct value
+
+2011-12-08 Tom Hacohen
+
+ * Binbuf + Strbuf + Ustrbuf: Added eina_*buf_manage_new_length.
+ Same as eina_(u)strbuf_manage_new except that it accepts a length
+ parameter.
EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
+ * @brief Create a new string buffer using the passed string. The passed
+ * string is used directly as the buffer, it's somehow the opposite function of
+ * @ref eina_binbuf_string_steal . The passed string must be malloced.
+ *
+ * @param str the string to manage
+ * @param length the length of the string.
+ * @return Newly allocated string buffer instance.
+ *
+ * This function creates a new string buffer. On error, @c NULL is
+ * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
+ * free the resources, use eina_binbuf_free().
+ *
+ * @see eina_binbuf_manage_new()
+ * @since 1.2.0
+ */
+EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+
+/**
* @brief Free a string buffer.
*
* @param buf The string buffer to free.
EAPI Eina_Strbuf *eina_strbuf_manage_new(char *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
+ * @brief Create a new string buffer using the passed string. The passed
+ * string is used directly as the buffer, it's somehow the opposite function of
+ * @ref eina_strbuf_string_steal . The passed string must be malloced.
+ *
+ * @param str the string to manage
+ * @param length the length of the string.
+ * @return Newly allocated string buffer instance.
+ *
+ * This function creates a new string buffer. On error, @c NULL is
+ * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
+ * free the resources, use eina_strbuf_free().
+ *
+ * @see eina_strbuf_manage_new()
+ * @since 1.2.0
+ */
+EAPI Eina_Strbuf *eina_strbuf_manage_new_length(char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+
+/**
* @brief Free a string buffer.
*
* @param buf The string buffer to free.
* @see eina_ustrbuf_string_get()
* @since 1.1.0
*/
-EAPI Eina_Strbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_UStrbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+
+/**
+ * @brief Create a new string buffer using the passed string. The passed
+ * string is used directly as the buffer, it's somehow the opposite function of
+ * @ref eina_ustrbuf_string_steal . The passed string must be malloced.
+ *
+ * @param str the string to manage
+ * @param length the length of the string.
+ * @return Newly allocated string buffer instance.
+ *
+ * This function creates a new string buffer. On error, @c NULL is
+ * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
+ * free the resources, use eina_ustrbuf_free().
+ *
+ * @see eina_ustrbuf_manage_new()
+ * @since 1.2.0
+ */
+EAPI Eina_UStrbuf *eina_ustrbuf_manage_new_length(Eina_Unicode *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
/**
* @brief Free a string buffer.
return buf;
}
+EAPI _STRBUF_STRUCT_NAME *
+_FUNC_EXPAND(manage_new_length)(_STRBUF_DATA_TYPE *str, size_t length)
+{
+ _STRBUF_STRUCT_NAME *buf =
+ eina_strbuf_common_manage_new(_STRBUF_CSIZE, (void *) str, length);
+ EINA_MAGIC_SET(buf, _STRBUF_MAGIC);
+ return buf;
+}
+
EAPI void
_FUNC_EXPAND(free)(_STRBUF_STRUCT_NAME *buf)
{
}
END_TEST
+START_TEST(binbuf_manage_simple)
+{
+ Eina_Binbuf *buf;
+ const unsigned char cbuf[] = "12\0 456 78\0 abcthis is some more random junk here!";
+ size_t size = sizeof(cbuf) - 1; /* We don't care about the real NULL */
+
+ eina_init();
+
+ buf = eina_binbuf_manage_new_length(cbuf, size);
+ fail_if(!buf);
+
+ fail_if(memcmp(eina_binbuf_string_get(buf), cbuf, size));
+ fail_if(size != eina_binbuf_length_get(buf));
+ eina_binbuf_append_length(buf, cbuf, size);
+ fail_if(memcmp(eina_binbuf_string_get(buf), cbuf, size));
+ fail_if(memcmp(eina_binbuf_string_get(buf) + size, cbuf, size));
+ fail_if(2 * size != eina_binbuf_length_get(buf));
+
+ eina_binbuf_free(buf);
+
+ eina_shutdown();
+}
+END_TEST
+
START_TEST(binbuf_insert)
{
#if 0