diff --git a/src/utils/unixsock.c b/src/utils/unixsock.c
index 6f4d5cc2e090350be92920ed3d074a18adaf091a..75221716e2479585f310c0c1dd263321dbd2735f 100644 (file)
--- a/src/utils/unixsock.c
+++ b/src/utils/unixsock.c
for (i = 0; i < column_count; ++i) {
char *next;
- if (! line) { /* this must no happen */
+ if (! line) { /* this must not happen */
sdb_log(SDB_LOG_ERR, "unixsock: Unexpected EOL while "
"parsing line (expected %i columns delimited by '%s'; "
"got %i): %s", column_count, delim,
++next;
}
- if (sdb_data_parse(line,
- types ? types[i] : SDB_TYPE_STRING, &data[i]))
- return -1;
+ if (types && (types[i] != SDB_TYPE_STRING)) {
+ if (sdb_data_parse(line, types[i], &data[i]))
+ return -1;
+ }
+ else {
+ /* Avoid a copy in common cases */
+ data[i].type = SDB_TYPE_STRING;
+ data[i].data.string = line;
+ }
line = next;
}
if (callback(client, (size_t)column_count, data, user_data))
return -1;
+
+ for (i = 0; i < column_count; ++i)
+ if (types && (types[i] != SDB_TYPE_STRING))
+ sdb_data_free_datum(&data[i]);
return 0;
} /* sdb_unixsock_client_process_one_line */