Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
8d237063
Commit
8d237063
authored
Oct 19, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/DeleteDisposer: new utility class
parent
62bfb1a2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
24 deletions
+55
-24
Makefile.am
Makefile.am
+1
-0
Client.hxx
src/client/Client.hxx
+0
-6
ClientList.cxx
src/client/ClientList.cxx
+2
-3
Directory.cxx
src/db/plugins/simple/Directory.cxx
+5
-3
Directory.hxx
src/db/plugins/simple/Directory.hxx
+0
-6
Manager.cxx
src/lib/nfs/Manager.cxx
+3
-6
DeleteDisposer.hxx
src/util/DeleteDisposer.hxx
+44
-0
No files found.
Makefile.am
View file @
8d237063
...
...
@@ -391,6 +391,7 @@ libutil_a_SOURCES = \
src/util/Macros.hxx
\
src/util/Cast.hxx
\
src/util/Clamp.hxx
\
src/util/DeleteDisposer.hxx
\
src/util/Alloc.cxx src/util/Alloc.hxx
\
src/util/VarSize.hxx
\
src/util/Error.cxx src/util/Error.hxx
\
...
...
src/client/Client.hxx
View file @
8d237063
...
...
@@ -51,12 +51,6 @@ public:
struct
playlist
&
playlist
;
struct
PlayerControl
&
player_control
;
struct
Disposer
{
void
operator
()(
Client
*
client
)
const
{
delete
client
;
}
};
unsigned
permission
;
/** the uid of the client process, or -1 if unknown */
...
...
src/client/ClientList.cxx
View file @
8d237063
...
...
@@ -20,8 +20,7 @@
#include "config.h"
#include "ClientList.hxx"
#include "ClientInternal.hxx"
#include <algorithm>
#include "util/DeleteDisposer.hxx"
#include <assert.h>
...
...
@@ -36,7 +35,7 @@ ClientList::Remove(Client &client)
void
ClientList
::
CloseAll
()
{
list
.
clear_and_dispose
(
Client
::
Disposer
());
list
.
clear_and_dispose
(
Delete
Disposer
());
}
void
...
...
src/db/plugins/simple/Directory.cxx
View file @
8d237063
...
...
@@ -31,6 +31,7 @@
#include "lib/icu/Collate.hxx"
#include "fs/Traits.hxx"
#include "util/Alloc.hxx"
#include "util/DeleteDisposer.hxx"
#include "util/Error.hxx"
#include <assert.h>
...
...
@@ -51,7 +52,7 @@ Directory::~Directory()
delete
mounted_database
;
songs
.
clear_and_dispose
(
Song
::
Disposer
());
children
.
clear_and_dispose
(
Disposer
());
children
.
clear_and_dispose
(
D
eleteD
isposer
());
}
void
...
...
@@ -61,7 +62,7 @@ Directory::Delete()
assert
(
parent
!=
nullptr
);
parent
->
children
.
erase_and_dispose
(
parent
->
children
.
iterator_to
(
*
this
),
Disposer
());
D
eleteD
isposer
());
}
const
char
*
...
...
@@ -110,7 +111,8 @@ Directory::PruneEmpty()
child
->
PruneEmpty
();
if
(
child
->
IsEmpty
())
child
=
children
.
erase_and_dispose
(
child
,
Disposer
());
child
=
children
.
erase_and_dispose
(
child
,
DeleteDisposer
());
else
++
child
;
}
...
...
src/db/plugins/simple/Directory.hxx
View file @
8d237063
...
...
@@ -53,12 +53,6 @@ struct Directory {
typedef
boost
::
intrusive
::
link_mode
<
link_mode
>
LinkMode
;
typedef
boost
::
intrusive
::
list_member_hook
<
LinkMode
>
Hook
;
struct
Disposer
{
void
operator
()(
Directory
*
directory
)
const
{
delete
directory
;
}
};
/**
* Pointers to the siblings of this directory within the
* parent directory. It is unused (undefined) in the root
...
...
src/lib/nfs/Manager.cxx
View file @
8d237063
...
...
@@ -21,6 +21,7 @@
#include "Manager.hxx"
#include "event/Loop.hxx"
#include "Log.hxx"
#include "util/DeleteDisposer.hxx"
#include <string.h>
...
...
@@ -65,9 +66,7 @@ NfsManager::~NfsManager()
CollectGarbage
();
connections
.
clear_and_dispose
([](
ManagedConnection
*
c
){
delete
c
;
});
connections
.
clear_and_dispose
(
DeleteDisposer
());
}
NfsConnection
&
...
...
@@ -95,9 +94,7 @@ NfsManager::CollectGarbage()
{
assert
(
GetEventLoop
().
IsInside
());
garbage
.
clear_and_dispose
([](
ManagedConnection
*
c
){
delete
c
;
});
garbage
.
clear_and_dispose
(
DeleteDisposer
());
}
void
...
...
src/util/DeleteDisposer.hxx
0 → 100644
View file @
8d237063
/*
* Copyright (C) 2015 Max Kellermann <max@duempel.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DELETE_DISPOSER_HXX
#define DELETE_DISPOSER_HXX
/**
* A disposer for boost::intrusive that invokes the "delete" operator
* on the given pointer.
*/
struct
DeleteDisposer
{
template
<
typename
T
>
void
operator
()(
T
*
t
)
{
delete
t
;
}
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment