]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleaup: migrate Logfile to CBDATA_CLASS API
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 2 Feb 2015 13:10:38 +0000 (05:10 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 2 Feb 2015 13:10:38 +0000 (05:10 -0800)
src/log/File.cc
src/log/File.h

index c80d2d62cda8892fe65baeea7c751b1f5b74d800..c18a3f1e2a61ec89792c58adad56cf5d9678d57d 100644 (file)
 #include "log/ModUdp.h"
 #include "log/TcpLogger.h"
 
-CBDATA_TYPE(Logfile);
+CBDATA_CLASS_INIT(Logfile);
+
+Logfile::Logfile(const char *aPath) :
+    sequence_number(0),
+    data(NULL),
+    f_linestart(NULL),
+    f_linewrite(NULL),
+    f_lineend(NULL),
+    f_flush(NULL),
+    f_rotate(NULL),
+    f_close(NULL)
+{
+    xstrncpy(path, aPath, sizeof(path));
+    flags.fatal = 0;
+}
 
 Logfile *
 logfileOpen(const char *path, size_t bufsz, int fatal_flag)
@@ -27,10 +41,8 @@ logfileOpen(const char *path, size_t bufsz, int fatal_flag)
     const char *patharg;
 
     debugs(50, DBG_IMPORTANT, "Logfile: opening log " << path);
-    CBDATA_INIT_TYPE(Logfile);
 
-    Logfile *lf = cbdataAlloc(Logfile);
-    xstrncpy(lf->path, path, MAXPATHLEN);
+    Logfile *lf = new Logfile(path);
     patharg = path;
     /* need to call the per-logfile-type code */
     if (strncmp(path, "stdio:", 6) == 0) {
@@ -61,7 +73,7 @@ logfileOpen(const char *path, size_t bufsz, int fatal_flag)
         else
             debugs(50, DBG_IMPORTANT, "logfileOpen: " << path << ": couldn't open!");
         lf->f_close(lf);
-        cbdataFree(lf);
+        delete lf;
         return NULL;
     }
     assert(lf->data != NULL);
@@ -80,7 +92,7 @@ logfileClose(Logfile * lf)
     debugs(50, DBG_IMPORTANT, "Logfile: closing log " << lf->path);
     lf->f_flush(lf);
     lf->f_close(lf);
-    cbdataFree(lf);
+    delete lf;
 }
 
 void
index fd9f646c9e20dd7066a968eecaa22a2824d16fda..dbeea19461d7a0e70b87939d47e15ef2b0a3f725 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef SQUID_SRC_LOG_FILE_H
 #define SQUID_SRC_LOG_FILE_H
 
+#include "cbdata.h"
 #include "dlink.h"
 
 #if HAVE_SYS_PARAM_H
@@ -36,8 +37,12 @@ typedef void LOGCLOSE(Logfile *);
 
 class Logfile
 {
+    CBDATA_CLASS(Logfile);
 
 public:
+    explicit Logfile(const char *aPath);
+    ~Logfile() {}
+
     char path[MAXPATHLEN];
 
     struct {