[Midnightbsd-cvs] src [12040] free memory from new fields.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Sep 14 09:28:25 EDT 2018


Revision: 12040
          http://svnweb.midnightbsd.org/src/?rev=12040
Author:   laffer1
Date:     2018-09-14 09:28:24 -0400 (Fri, 14 Sep 2018)
Log Message:
-----------
free memory from new fields. add some to info output.

Modified Paths:
--------------
    trunk/lib/libmport/info.c
    trunk/lib/libmport/pkgmeta.c

Property Changed:
----------------
    trunk/lib/libmport/info.c

Modified: trunk/lib/libmport/info.c
===================================================================
--- trunk/lib/libmport/info.c	2018-09-14 13:10:28 UTC (rev 12039)
+++ trunk/lib/libmport/info.c	2018-09-14 13:28:24 UTC (rev 12040)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2015, 2016 Lucas Holt
+ * Copyright (c) 2015, 2016, 2018 Lucas Holt
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,7 @@
 #include "mport_private.h"
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <err.h>
 #include <unistd.h>
 
@@ -40,11 +41,13 @@
 {
 	mportIndexEntry **indexEntry;
 	mportPackageMeta **packs;
-	char *status, *origin;
+	char *status, *origin, *flavor, *deprecated;
 	char *os_release;
 	char *cpe;
 	int locked = 0;
+	int no_shlib_provided = 0;
 	char *info_text = NULL;
+	time_t expirationDate;
 
 	if (packageName == NULL) {
 		SET_ERROR(MPORT_ERR_FATAL, "Package name not found.");
@@ -70,6 +73,9 @@
 		origin = strdup("");
 		os_release = strdup("");
 		cpe = strdup("");
+		flavor = strdup("");
+		deprecated = strdup("N/A");
+		expirationDate = 0;
 	} else {
 		status = (*packs)->version;
 		origin = (*packs)->origin;
@@ -76,19 +82,30 @@
 		os_release = (*packs)->os_release;
 		cpe = (*packs)->cpe;
 		locked = (*packs)->locked;
+		no_shlib_provided = (*packs)->no_provide_shlib;
+		flavor = (*packs)->flavor;
+		deprecated  = (*packs)->deprecated;
+		if (deprecated[0] == '\0') {
+			deprecated = strdup("N/A");
+		}
+		expirationDate = (*packs)->expiration_date;
 	}
 
 	asprintf(&info_text,
-	         "%s\nlatest: %s\ninstalled: %s\nlicense: %s\norigin: %s\nos: %s\n\n%s\ncpe: %s\nlocked: %s\n",
-	         (*indexEntry)->pkgname,
-	         (*indexEntry)->version,
-	         status,
-	         (*indexEntry)->license,
-	         origin,
-	         os_release,
-	         (*indexEntry)->comment,
-	         cpe,
-	         locked ? "yes" : "no");
+		 "%s\nlatest: %s\ninstalled: %s\nlicense: %s\norigin: %s\nflavor: %s\nos: %s\n\n%s\ncpe: %s\nlocked: %s\nno_shlib_provided: %s\ndeprecated:%s\nexpirationDate:%s\n",
+		 (*indexEntry)->pkgname,
+		 (*indexEntry)->version,
+		 status,
+		 (*indexEntry)->license,
+		 origin,
+		 flavor,
+		 os_release,
+		 (*indexEntry)->comment,
+		 cpe,
+		 locked ? "yes" : "no"),
+		no_shlib_provided ? "yes" : "no",
+		deprecated,
+		expirationDate == 0 ? "N/A" : ctime(&expirationDate);
 
 	if (packs == NULL) {
 		free(status);
@@ -95,6 +112,8 @@
 		free(origin);
 		free(os_release);
 		free(cpe);
+		free(flavor);
+		free(deprecated);
 	} else
 		mport_pkgmeta_vec_free(packs);
 


Property changes on: trunk/lib/libmport/info.c
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libmport/pkgmeta.c
===================================================================
--- trunk/lib/libmport/pkgmeta.c	2018-09-14 13:10:28 UTC (rev 12039)
+++ trunk/lib/libmport/pkgmeta.c	2018-09-14 13:28:24 UTC (rev 12040)
@@ -51,38 +51,42 @@
 MPORT_PUBLIC_API void
 mport_pkgmeta_free(mportPackageMeta *pack)
 {
-    int i;
+	int i;
 
-    free(pack->name);
-    pack->name = NULL;
-    free(pack->version);
-    pack->version = NULL;
-    free(pack->lang);
-    pack->lang = NULL;
-    free(pack->comment);
-    pack->comment = NULL;
-    free(pack->desc);
-    pack->desc = NULL;
-    free(pack->prefix);
-    pack->prefix = NULL;
-    free(pack->origin);
-    pack->origin = NULL;
-    free(pack->os_release);
-    pack->os_release = NULL;
-    free(pack->cpe);
-    pack->cpe = NULL;
+	free(pack->name);
+	pack->name = NULL;
+	free(pack->version);
+	pack->version = NULL;
+	free(pack->lang);
+	pack->lang = NULL;
+	free(pack->comment);
+	pack->comment = NULL;
+	free(pack->desc);
+	pack->desc = NULL;
+	free(pack->prefix);
+	pack->prefix = NULL;
+	free(pack->origin);
+	pack->origin = NULL;
+	free(pack->os_release);
+	pack->os_release = NULL;
+	free(pack->cpe);
+	pack->cpe = NULL;
+	free(pack->deprecated);
+	pack->deprecated = NULL;
+	free(pack->flavor);
+	pack->flavor = NULL;
 
-    i = 0;
-    if (pack->categories != NULL) {
-        while (pack->categories[i] != NULL) {
-            free(pack->categories[i]);
-            pack->categories[i] = NULL;
-            i++;
-        }
-    }
+	i = 0;
+	if (pack->categories != NULL) {
+		while (pack->categories[i] != NULL) {
+			free(pack->categories[i]);
+			pack->categories[i] = NULL;
+			i++;
+		}
+	}
 
-    free(pack->categories);
-    free(pack);
+	free(pack->categories);
+	free(pack);
 }
 
 /* free a vector of mportPackageMeta pointers */



More information about the Midnightbsd-cvs mailing list