You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by "stegemr (via GitHub)" <gi...@apache.org> on 2023/03/10 13:52:06 UTC

[GitHub] [celix] stegemr commented on a diff in pull request #476: Feature/refactor bundle cache

stegemr commented on code in PR #476:
URL: https://github.com/apache/celix/pull/476#discussion_r1132405089


##########
libs/utils/include/celix_utils.h:
##########
@@ -46,11 +46,42 @@ char* celix_utils_strdup(const char *str);
  */
 unsigned int celix_utils_stringHash(const char* string);
 
+/**
+ * The proposed buffer size to use for celix_utils_writeOrCreateString with a buffer on the stcck.
+ */
+#define CELIX_DEFAULT_STRING_CREATE_BUFFER_SIZE 512
+
+/**`
+ * @brief Format a string to the provided buffer or a newly allocated buffer if the provided buffer is to small.
+ * @param[in,out] buffer The buffer to write the formatted string to.
+ * @param[in] bufferSize The size of the buffer.
+ * @param[in] format The format string.
+ * @param[in] ... The arguments for the format string.
+ * @return The formatted string in the provided buffer or a newly allocated buffer if the provided buffer is to small.
+ */
+char* celix_utils_writeOrCreateString(char* buffer, size_t bufferSize, const char* format, ...)
+    __attribute__((format(printf, 3, 4)));
+
+/**
+ * @brief Free the provided str if the str is not equal to the provided buffer.
+ * @note This function is useful combined with celix_utils_writeOrCreateString.
+ * @param buffer The buffer to compare the str to.
+ * @param str The string to free if it is not equal to the buffer.
+ */
+void celix_utils_freeStringIfNeeded(const char* buffer, char* str);

Review Comment:
   celix_utils_freeStringIfNeeded propose to change to celix_utils_freeStringIfNotEqual



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org