[68684] trunk/base/src/cregistry/entry.c

jmr at macports.org jmr at macports.org
Thu Jun 10 04:20:19 PDT 2010


Revision: 68684
          http://trac.macports.org/changeset/68684
Author:   jmr at macports.org
Date:     2010-06-10 04:20:15 -0700 (Thu, 10 Jun 2010)
Log Message:
-----------
clean up use of reg_strcat

Modified Paths:
--------------
    trunk/base/src/cregistry/entry.c

Modified: trunk/base/src/cregistry/entry.c
===================================================================
--- trunk/base/src/cregistry/entry.c	2010-06-10 07:28:20 UTC (rev 68683)
+++ trunk/base/src/cregistry/entry.c	2010-06-10 11:20:15 UTC (rev 68684)
@@ -78,10 +78,10 @@
  * @param [in,out] dst_space number of characters `dst` can hold
  * @param [in] src           string to concatenate to `dst`
  */
-static int reg_strcat(char** dst, int* dst_len, int* dst_space, char* src) {
-    int src_len = strlen(src);
-    int result_len = *dst_len + src_len;
-    if (result_len >= *dst_space) {
+static int reg_strcat(char** dst, size_t* dst_len, size_t* dst_space, char* src) {
+    size_t src_len = strlen(src);
+    size_t result_len = *dst_len + src_len;
+    if (result_len > *dst_space) {
         char* new_dst;
         *dst_space *= 2;
         if (*dst_space < result_len) {
@@ -511,8 +511,7 @@
     int i;
     char* kwd = " WHERE ";
     char* query;
-    int query_len = 29;
-    int query_space = 29;
+    size_t query_len, query_space;
     int result;
     /* get the strategy */
     char* op = reg_strategy_op(strategy, errPtr);
@@ -524,6 +523,7 @@
     if (!query) {
         return -1;
     }
+    query_len = query_space = strlen(query);
     for (i=0; i<key_count; i++) {
         char* cond = sqlite3_mprintf(op, keys[i], vals[i]);
         if (!cond || !reg_strcat(&query, &query_len, &query_space, kwd)
@@ -535,7 +535,7 @@
         kwd = " AND ";
     }
     /* do the query */
-    result = reg_all_entries(reg, query, query_len, entries, errPtr);
+    result = reg_all_entries(reg, query, -1, entries, errPtr);
     free(query);
     return result;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100610/c3c444e9/attachment.html>


More information about the macports-changes mailing list