pnoltes commented on code in PR #470:
URL: https://github.com/apache/celix/pull/470#discussion_r1399584425
##########
libs/utils/src/properties.c:
##########
@@ -191,324 +476,423 @@ static void parseLine(const char* line,
celix_properties_t *props) {
}
if (!isComment) {
- //printf("putting 'key'/'value' '%s'/'%s' in properties\n",
utils_stringTrim(key), utils_stringTrim(value));
+ // printf("putting 'key'/'value' '%s'/'%s' in properties\n",
utils_stringTrim(key), utils_stringTrim(value));
celix_properties_set(props, celix_utils_trimInPlace(key),
celix_utils_trimInPlace(value));
}
- if(key) {
+ if (key) {
free(key);
- }
- if(value) {
free(value);
}
-
}
+celix_properties_t* celix_properties_loadWithStream(FILE* file) {
+ if (file == NULL) {
+ return NULL;
+ }
-/**********************************************************************************************************************
-
**********************************************************************************************************************
- * Updated API
-
**********************************************************************************************************************
-
**********************************************************************************************************************/
+ celix_autoptr(celix_properties_t) props = celix_properties_create();
+ if (!props) {
+ celix_err_push("Failed to create properties");
+ return NULL;
+ }
+ int rc = fseek(file, 0, SEEK_END);
+ if (rc != 0) {
+ celix_err_pushf("Cannot seek to end of file. Got error %i", errno);
+ return NULL;
+ }
+ size_t fileSize = ftell(file);
+ rc = fseek(file, 0, SEEK_SET);
+ if (rc != 0) {
+ celix_err_pushf("Cannot seek to start of file. Got error %i", errno);
+ return NULL;
+ }
Review Comment:
I think this is wise, but what is a good max properties file size?
Also if we add a max properties file size, I think this should be
configurable with a conan/cmake build option.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]