From ba51045d9e85b8e48afed629d6d87ac3338acd46 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 29 Jan 2013 23:20:19 +0100 Subject: refcount: convert to C++ --- src/archive/Bzip2ArchivePlugin.cxx | 9 ++++----- src/archive/Iso9660ArchivePlugin.cxx | 9 ++++----- src/archive/ZzipArchivePlugin.cxx | 9 ++++----- 3 files changed, 12 insertions(+), 15 deletions(-) (limited to 'src/archive') diff --git a/src/archive/Bzip2ArchivePlugin.cxx b/src/archive/Bzip2ArchivePlugin.cxx index be7388d5..f9371812 100644 --- a/src/archive/Bzip2ArchivePlugin.cxx +++ b/src/archive/Bzip2ArchivePlugin.cxx @@ -29,7 +29,7 @@ #include "InputInternal.hxx" #include "InputStream.hxx" #include "InputPlugin.hxx" -#include "refcount.h" +#include "util/RefCount.hxx" #include #include @@ -45,18 +45,17 @@ struct Bzip2ArchiveFile { struct archive_file base; - struct refcount ref; + RefCount ref; char *name; struct input_stream *istream; Bzip2ArchiveFile() { archive_file_init(&base, &bz2_archive_plugin); - refcount_init(&ref); } void Unref() { - if (!refcount_dec(&ref)) + if (!ref.Decrement()) return; g_free(name); @@ -174,7 +173,7 @@ Bzip2InputStream::Bzip2InputStream(Bzip2ArchiveFile &_context, const char *uri, :base(bz2_inputplugin, uri, mutex, cond), archive(&_context), eof(false) { - refcount_inc(&archive->ref); + archive->ref.Increment(); } Bzip2InputStream::~Bzip2InputStream() diff --git a/src/archive/Iso9660ArchivePlugin.cxx b/src/archive/Iso9660ArchivePlugin.cxx index 895087ef..344cdac6 100644 --- a/src/archive/Iso9660ArchivePlugin.cxx +++ b/src/archive/Iso9660ArchivePlugin.cxx @@ -29,7 +29,7 @@ #include "InputInternal.hxx" #include "InputStream.hxx" #include "InputPlugin.hxx" -#include "refcount.h" +#include "util/RefCount.hxx" #include #include @@ -44,14 +44,13 @@ struct Iso9660ArchiveFile { struct archive_file base; - struct refcount ref; + RefCount ref; iso9660_t *iso; Iso9660ArchiveFile(iso9660_t *_iso) :iso(_iso) { archive_file_init(&base, &iso9660_archive_plugin); - refcount_init(&ref); } ~Iso9660ArchiveFile() { @@ -59,7 +58,7 @@ struct Iso9660ArchiveFile { } void Unref() { - if (refcount_dec(&ref)) + if (ref.Decrement()) delete this; } @@ -161,7 +160,7 @@ struct Iso9660InputStream { base.ready = true; base.size = statbuf->size; - refcount_inc(&archive->ref); + archive->ref.Increment(); } ~Iso9660InputStream() { diff --git a/src/archive/ZzipArchivePlugin.cxx b/src/archive/ZzipArchivePlugin.cxx index 4075e217..1b089a48 100644 --- a/src/archive/ZzipArchivePlugin.cxx +++ b/src/archive/ZzipArchivePlugin.cxx @@ -29,7 +29,7 @@ #include "InputInternal.hxx" #include "InputStream.hxx" #include "InputPlugin.hxx" -#include "refcount.h" +#include "util/RefCount.hxx" #include #include @@ -38,17 +38,16 @@ struct ZzipArchiveFile { struct archive_file base; - struct refcount ref; + RefCount ref; ZZIP_DIR *dir; ZzipArchiveFile() { archive_file_init(&base, &zzip_archive_plugin); - refcount_init(&ref); } void Unref() { - if (!refcount_dec(&ref)) + if (!ref.Decrement()) return; //close archive @@ -136,7 +135,7 @@ struct ZzipInputStream { zzip_file_stat(file, &z_stat); base.size = z_stat.st_size; - refcount_inc(&archive->ref); + archive->ref.Increment(); } ~ZzipInputStream() { -- cgit v1.2.3