summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9f22d29)
raw | patch | inline | side by side (parent: 9f22d29)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 2 Jan 2015 14:53:54 +0000 (15:53 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 2 Jan 2015 14:53:54 +0000 (15:53 +0100) |
src/utils/unixsock.c | patch | blob | history |
diff --git a/src/utils/unixsock.c b/src/utils/unixsock.c
index 653664145910084cd7adc2e7b59de3ad2d597e56..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;
}
return -1;
for (i = 0; i < column_count; ++i)
- sdb_data_free_datum(&data[i]);
+ if (types && (types[i] != SDB_TYPE_STRING))
+ sdb_data_free_datum(&data[i]);
return 0;
} /* sdb_unixsock_client_process_one_line */