From 702c3ee5560abe53ed9cddc57f508aa6ccb71243 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Tue, 1 Feb 2011 14:54:51 +0100 Subject: [PATCH] Add simple way to add string elements to db_list_ctx --- bacula/src/cats/cats.h | 7 +++++++ bacula/src/cats/sql.c | 6 +----- 2 files changed, 8 insertions(+), 5 deletions(-) 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; } -- 2.39.5