[70473] branches/gsoc10-configfiles/base/src

and.damore at macports.org and.damore at macports.org
Tue Aug 10 12:00:09 PDT 2010


Revision: 70473
          http://trac.macports.org/changeset/70473
Author:   and.damore at macports.org
Date:     2010-08-10 12:00:09 -0700 (Tue, 10 Aug 2010)
Log Message:
-----------
fixed commands for registry::entry "imagefiles_with_md5" and "files_with_md5"

Modified Paths:
--------------
    branches/gsoc10-configfiles/base/src/cregistry/entry.c
    branches/gsoc10-configfiles/base/src/registry2.0/entryobj.c

Modified: branches/gsoc10-configfiles/base/src/cregistry/entry.c
===================================================================
--- branches/gsoc10-configfiles/base/src/cregistry/entry.c	2010-08-10 16:51:49 UTC (rev 70472)
+++ branches/gsoc10-configfiles/base/src/cregistry/entry.c	2010-08-10 19:00:09 UTC (rev 70473)
@@ -1127,7 +1127,8 @@
         if (r == SQLITE_DONE) {
             *files = result_files;
             *md5sums = result_md5sums;
-            /*  this is lacking result_count_md5sums, shouldn't be necessary */
+            /*  this is lacking result_count_md5sums, shouldn't be necessary as 
+                both counts will always be the same */
             return result_count_files;
         } else {
             int i;
@@ -1284,7 +1285,8 @@
         if (r == SQLITE_DONE) {
             *files = result_files;
             *md5sums = result_md5sums;
-            /*  this is lacking result_count_md5sums, shouldn't be necessary */
+            /*  this is lacking result_count_md5sums, shouldn't be necessary as 
+                both counts will always be the same */
             return result_count_files;
         } else {
             int i;

Modified: branches/gsoc10-configfiles/base/src/registry2.0/entryobj.c
===================================================================
--- branches/gsoc10-configfiles/base/src/registry2.0/entryobj.c	2010-08-10 16:51:49 UTC (rev 70472)
+++ branches/gsoc10-configfiles/base/src/registry2.0/entryobj.c	2010-08-10 19:00:09 UTC (rev 70473)
@@ -277,38 +277,42 @@
     } else {
         char** files;
         char** md5sums;
-        char** mixed;
+        char** mixed=NULL;
         reg_error error;
         int file_count = reg_entry_files_with_md5(entry, &files, &md5sums, &error);
-        int i;
+        int i,k;
         if (file_count >= 0) {
             Tcl_Obj** objs;
             int retval = TCL_ERROR;
-            
             mixed=malloc(2*file_count*sizeof(char *));
-            for (i=0; i<2*file_count; i+=2) {
-                /*  could Tcl_* functions instead, Tcl_NewListObj and then
-                Tcl_ListObjAppendElement on Tcl_NewString() files[i] md5sums[i]
-                    */
-                mixed[i+0]=files[i];
-                mixed[i+1]=md5sums[i];
-            }
-            if (list_string_to_obj(&objs, mixed, 2*file_count, &error)) {
-                Tcl_Obj* result = Tcl_NewListObj(2*file_count, objs);
-                Tcl_SetObjResult(interp, result);
-                free(objs);
-                retval = TCL_OK;
+            if (!mixed) { 
+                /*  any meaningful return code here? */
+                return -1;
             } else {
-                retval = registry_failed(interp, &error);
+                for (i=0; k=2*i,i<file_count; i++) {
+                    /*  could Tcl_* functions instead, Tcl_NewListObj and then
+                    Tcl_ListObjAppendElement on Tcl_NewString() files[i] md5sums[i]
+                        */
+                    mixed[k+0]=files[i];
+                    mixed[k+1]=md5sums[i];
+                }
+                if (list_string_to_obj(&objs, mixed, 2*file_count, &error)) {
+                    Tcl_Obj* result = Tcl_NewListObj(2*file_count, objs);
+                    Tcl_SetObjResult(interp, result);
+                    free(objs);
+                    retval = TCL_OK;
+                } else {
+                    retval = registry_failed(interp, &error);
+                }
+                for (i=0; i<file_count; i++) {
+                    free(files[i]);
+                    free(md5sums[i]);
+                }
+                free(files);
+                free(md5sums);
+                free(mixed);
+                return retval;
             }
-            for (i=0; i<file_count; i++) {
-                free(files[i]);
-                free(md5sums[i]);
-            }
-            free(files);
-            free(md5sums);
-            free(mixed);
-            return retval;
         }
         return registry_failed(interp, &error);
     }
@@ -359,37 +363,42 @@
     } else {
         char** files;
         char** md5sums;
-        char** mixed;
+        char** mixed=NULL;
         reg_error error;
         int file_count = reg_entry_imagefiles_with_md5(entry, &files, &md5sums, &error);
-        int i;
+        int i,k;
         if (file_count >= 0) {
             Tcl_Obj** objs;
             int retval = TCL_ERROR;
             mixed=malloc(2*file_count*sizeof(char *));
-            for (i=0; i<2*file_count; i+=2) {
-                /*  could Tcl_* functions instead, Tcl_NewListObj and then
-                Tcl_ListObjAppendElement on Tcl_NewString() files[i] md5sums[i]
-                    */
-                mixed[i+0]=files[i];
-                mixed[i+1]=md5sums[i];
-            }
-            if (list_string_to_obj(&objs, mixed, 2*file_count, &error)) {
-                Tcl_Obj* result = Tcl_NewListObj(2*file_count, objs);
-                Tcl_SetObjResult(interp, result);
-                free(objs);
-                retval = TCL_OK;
+            if (!mixed) { 
+                /*  any meaningful return code here? */
+                return -1;
             } else {
-                retval = registry_failed(interp, &error);
+                for (i=0; k=2*i,i<file_count; i++) {
+                    /*  could Tcl_* functions instead, Tcl_NewListObj and then
+                    Tcl_ListObjAppendElement on Tcl_NewString() files[i] md5sums[i]
+                        */
+                    mixed[k+0]=files[i];
+                    mixed[k+1]=md5sums[i];
+                }
+                if (list_string_to_obj(&objs, mixed, 2*file_count, &error)) {
+                    Tcl_Obj* result = Tcl_NewListObj(2*file_count, objs);
+                    Tcl_SetObjResult(interp, result);
+                    free(objs);
+                    retval = TCL_OK;
+                } else {
+                    retval = registry_failed(interp, &error);
+                }
+                for (i=0; i<file_count; i++) {
+                    free(files[i]);
+                    free(md5sums[i]);
+                }
+                free(files);
+                free(md5sums);
+                free(mixed);
+                return retval;
             }
-            for (i=0; i<file_count; i++) {
-                free(files[i]);
-                free(md5sums[i]);
-            }
-            free(files);
-            free(md5sums);
-            free(mixed);
-            return retval;
         }
         return registry_failed(interp, &error);
     }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100810/f55e0e19/attachment.html>


More information about the macports-changes mailing list