pnoltes commented on code in PR #470:
URL: https://github.com/apache/celix/pull/470#discussion_r1399582716


##########
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);

Review Comment:
   added ftell return check and error injection test



-- 
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-unsubscr...@celix.apache.org

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

Reply via email to