From: Eric Bollengier Date: Tue, 1 Feb 2011 13:54:51 +0000 (+0100) Subject: Add simple way to add string elements to db_list_ctx X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4f2886366a59bd1eeb6f79dac06de064a8ae16d2;p=bacula%2Fbacula Add simple way to add string elements to db_list_ctx --- diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index d70540f6ea..970143dc46 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -395,6 +395,13 @@ public: count += str.count; } } + void cat(const char *str) { + if (count > 0) { + pm_strcat(list, ","); + } + pm_strcat(list, str); + count++; + } private: db_list_ctx(const db_list_ctx&); /* prohibit pass by value */ db_list_ctx &operator=(const db_list_ctx&); /* prohibit class assignment */ diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index 8c1105d2c6..5d822c034d 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -106,11 +106,7 @@ int db_list_handler(void *ctx, int num_fields, char **row) { db_list_ctx *lctx = (db_list_ctx *)ctx; if (num_fields == 1 && row[0]) { - if (lctx->list[0]) { - pm_strcat(lctx->list, ","); - } - pm_strcat(lctx->list, row[0]); - lctx->count++; + lctx->cat(row[0]); } return 0; }