There is no need to use a buffer at all.
[oweals/opkg-lede.git] / libopkg / pkg_dest.c
index b5cfe23fa924586e1a974b590cb8a9bb2c23c51b..083f97c9140e819a678ee6d03b7cd3cfbf66138c 100644 (file)
 #include "opkg_conf.h"
 #include "opkg_cmd.h"
 #include "opkg_defines.h"
+#include "libbb/libbb.h"
 
 int pkg_dest_init(pkg_dest_t *dest, const char *name, const char *root_dir,const char * lists_dir)
 {
-    dest->name = strdup(name);
+    dest->name = xstrdup(name);
 
     /* Guarantee that dest->root_dir ends with a '/' */
     if (str_ends_with(root_dir, "/")) {
-       dest->root_dir = strdup(root_dir);
+       dest->root_dir = xstrdup(root_dir);
     } else {
        sprintf_alloc(&dest->root_dir, "%s/", root_dir);
     }
@@ -55,11 +56,6 @@ int pkg_dest_init(pkg_dest_t *dest, const char *name, const char *root_dir,const
     sprintf_alloc(&dest->status_file_name, "%s/%s",
                  dest->opkg_dir, OPKG_STATUS_FILE_SUFFIX);
 
-    sprintf_alloc(&dest->status_file_tmp_name, "%s/%s.tmp",
-                 dest->opkg_dir, OPKG_STATUS_FILE_SUFFIX);
-
-    dest->status_file = NULL;
-
     return 0;
 }
 
@@ -83,13 +79,5 @@ void pkg_dest_deinit(pkg_dest_t *dest)
     free(dest->status_file_name);
     dest->status_file_name = NULL;
 
-    free(dest->status_file_tmp_name);
-    dest->status_file_tmp_name = NULL;
-
-    if (dest->status_file) {
-       fclose(dest->status_file);
-    }
-    dest->status_file = NULL;
-
     dest->root_dir = NULL;
 }