<pre style='margin:0'>
Umesh Singla (umeshksingla) pushed a commit to branch gsoc17-migrate
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/efc513a68759d124b5c3983240c5faddfd2705e3">https://github.com/macports/macports-base/commit/efc513a68759d124b5c3983240c5faddfd2705e3</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit efc513a68759d124b5c3983240c5faddfd2705e3
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Sat Aug 26 01:15:04 2017 +0530
<span style='display:block; white-space:pre;color:#404040;'> Convert variants to variant string before passing
</span>---
src/cregistry/snapshot.c | 29 +++++++++++++++++++++--------
src/cregistry/snapshot.h | 3 ++-
2 files changed, 23 insertions(+), 9 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/snapshot.c b/src/cregistry/snapshot.c
</span><span style='display:block; white-space:pre;color:#808080;'>index c9d9b26..9f0b1d4 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/snapshot.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/snapshot.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -329,21 +329,35 @@ int reg_snapshot_ports_get(reg_snapshot* snapshot, port*** ports, reg_error* err
</span> current_port->name = strdup(port_name);
current_port->requested = requested;
current_port->state = strdup(state);
<span style='display:block; white-space:pre;background:#ffe0e0;'>- current_port->variants = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> variants = (variant**) malloc(sizeof(variant*));
if (!variants) {
return -1;
}
int variant_count = reg_snapshot_ports_get_helper(reg, snapshot_port_id, &variants, errPtr);
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if (variant_count > 0) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- current_port->variants = variants;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ current_port->variant_count = variant_count;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char* variantstr = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (current_port->variant_count > 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int j;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ variantstr = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for(j = 0; j < current_port->variant_count; j++) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (asprintf(&variantstr, "%s%s",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (*variants)[j].variant_sign,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (*variants)[j].variant_name) < 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ current_port->variants = strdup(variantstr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ free(variantstr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ current_port->variants = '\0';
</span> }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> if (!reg_listcat((void***)&result, &result_count, &result_space, current_port)) {
r = SQLITE_ERROR;
}
int i;
<span style='display:block; white-space:pre;background:#ffe0e0;'>- for (i=0; i < variant_count; i++) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for (i = 0; i < variant_count; i++) {
</span> free(variants[i]);
}
free(variants);
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -364,7 +378,6 @@ int reg_snapshot_ports_get(reg_snapshot* snapshot, port*** ports, reg_error* err
</span> if (r == SQLITE_DONE) {
*ports = result;
return result_count;
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> } else {
int i;
for (i=0; i<result_count; i++) {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -381,7 +394,8 @@ int reg_snapshot_ports_get(reg_snapshot* snapshot, port*** ports, reg_error* err
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-int reg_snapshot_ports_get_helper(reg_registry* reg, sqlite_int64 snapshot_port_id, variant*** variants, reg_error* errPtr) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int reg_snapshot_ports_get_helper(reg_registry* reg, sqlite_int64 snapshot_port_id,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ variant*** variants, reg_error* errPtr) {
</span>
sqlite3_stmt* stmt = NULL;
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -419,7 +433,6 @@ int reg_snapshot_ports_get_helper(reg_registry* reg, sqlite_int64 snapshot_port_
</span> if (!reg_listcat((void***)&result, &result_count, &result_space, element)) {
r = SQLITE_ERROR;
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- //free(element);
</span> break;
case SQLITE_DONE:
case SQLITE_BUSY:
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/snapshot.h b/src/cregistry/snapshot.h
</span><span style='display:block; white-space:pre;color:#808080;'>index 16cbe20..5633199 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/snapshot.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/snapshot.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -46,7 +46,8 @@ typedef struct {
</span> char* name;
int requested;
char* state;
<span style='display:block; white-space:pre;background:#ffe0e0;'>- variant* variants;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int variant_count;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char* variants;
</span> } port;
typedef struct {
</pre><pre style='margin:0'>
</pre>