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
f8cbba18
Commit
f8cbba18
authored
Oct 13, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/Alloc: remove unused library
parent
635ec3ce
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
265 deletions
+0
-265
Walk.cxx
src/db/update/Walk.cxx
+0
-1
Alloc.cxx
src/util/Alloc.cxx
+0
-111
Alloc.hxx
src/util/Alloc.hxx
+0
-86
ConcatString.hxx
src/util/ConcatString.hxx
+0
-66
meson.build
src/util/meson.build
+0
-1
No files found.
src/db/update/Walk.cxx
View file @
f8cbba18
...
...
@@ -33,7 +33,6 @@
#include "storage/FileInfo.hxx"
#include "input/InputStream.hxx"
#include "input/Error.hxx"
#include "util/Alloc.hxx"
#include "util/StringCompare.hxx"
#include "util/UriExtract.hxx"
#include "Log.hxx"
...
...
src/util/Alloc.cxx
deleted
100644 → 0
View file @
635ec3ce
/*
* Copyright 2003-2021 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "Alloc.hxx"
#include "ConcatString.hxx"
#include <cstring>
#include <unistd.h>
[[
noreturn
]]
static
void
oom
()
{
(
void
)
write
(
STDERR_FILENO
,
"Out of memory
\n
"
,
14
);
std
::
_Exit
(
1
);
}
void
*
xalloc
(
size_t
size
)
{
auto
p
=
std
::
malloc
(
size
);
if
(
gcc_unlikely
(
p
==
nullptr
))
oom
();
return
p
;
}
void
*
xmemdup
(
const
void
*
s
,
size_t
size
)
{
auto
p
=
xalloc
(
size
);
std
::
memcpy
(
p
,
s
,
size
);
return
p
;
}
char
*
xstrdup
(
const
char
*
s
)
{
char
*
p
=
strdup
(
s
);
if
(
gcc_unlikely
(
p
==
nullptr
))
oom
();
return
p
;
}
char
*
xstrndup
(
const
char
*
s
,
size_t
n
)
{
#ifdef HAVE_STRNDUP
char
*
p
=
strndup
(
s
,
n
);
if
(
gcc_unlikely
(
p
==
nullptr
))
oom
();
#else
auto
p
=
(
char
*
)
xalloc
(
n
+
1
);
std
::
memcpy
(
p
,
s
,
n
);
p
[
n
]
=
0
;
#endif
return
p
;
}
template
<
typename
...
Args
>
gcc_malloc
gcc_nonnull_all
static
inline
char
*
t_xstrcatdup
(
Args
&&
...
args
)
{
constexpr
size_t
n
=
sizeof
...(
args
);
size_t
lengths
[
n
];
const
size_t
total
=
FillLengths
(
lengths
,
args
...);
auto
p
=
(
char
*
)
xalloc
(
total
+
1
);
*
StringCat
(
p
,
lengths
,
args
...)
=
0
;
return
p
;
}
char
*
xstrcatdup
(
const
char
*
a
,
const
char
*
b
)
{
return
t_xstrcatdup
(
a
,
b
);
}
char
*
xstrcatdup
(
const
char
*
a
,
const
char
*
b
,
const
char
*
c
)
{
return
t_xstrcatdup
(
a
,
b
,
c
);
}
char
*
xstrcatdup
(
const
char
*
a
,
const
char
*
b
,
const
char
*
c
,
const
char
*
d
)
{
return
t_xstrcatdup
(
a
,
b
,
c
,
d
);
}
src/util/Alloc.hxx
deleted
100644 → 0
View file @
635ec3ce
/*
* Copyright 2003-2021 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ALLOC_HXX
#define MPD_ALLOC_HXX
#include "Compiler.h"
#include <cstddef>
/**
* Allocate memory. Use free() to free it.
*
* This function never fails; in out-of-memory situations, it aborts
* the process.
*/
gcc_malloc
gcc_returns_nonnull
void
*
xalloc
(
size_t
size
);
/**
* Duplicate memory. Use free() to free it.
*
* This function never fails; in out-of-memory situations, it aborts
* the process.
*/
gcc_malloc
gcc_returns_nonnull
gcc_nonnull_all
void
*
xmemdup
(
const
void
*
s
,
size_t
size
);
/**
* Duplicate a string. Use free() to free it.
*
* This function never fails; in out-of-memory situations, it aborts
* the process.
*/
gcc_malloc
gcc_returns_nonnull
gcc_nonnull_all
char
*
xstrdup
(
const
char
*
s
);
/**
* Duplicate a string. Use free() to free it.
*
* This function never fails; in out-of-memory situations, it aborts
* the process.
*/
gcc_malloc
gcc_returns_nonnull
gcc_nonnull_all
char
*
xstrndup
(
const
char
*
s
,
size_t
n
);
/**
* Concatenate two strings, returning a new allocation. Use free() to
* free it.
*
* This function never fails; in out-of-memory situations, it aborts
* the process.
*/
gcc_malloc
gcc_returns_nonnull
gcc_nonnull_all
char
*
xstrcatdup
(
const
char
*
a
,
const
char
*
b
);
gcc_malloc
gcc_returns_nonnull
gcc_nonnull_all
char
*
xstrcatdup
(
const
char
*
a
,
const
char
*
b
,
const
char
*
c
);
gcc_malloc
gcc_returns_nonnull
gcc_nonnull_all
char
*
xstrcatdup
(
const
char
*
a
,
const
char
*
b
,
const
char
*
c
,
const
char
*
d
);
#endif
src/util/ConcatString.hxx
deleted
100644 → 0
View file @
635ec3ce
/*
* Copyright (C) 2014-2017 Max Kellermann <max.kellermann@gmail.com>
*
* 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 CONCAT_STRING_HXX
#define CONCAT_STRING_HXX
#include <algorithm>
#include <string.h>
template
<
typename
...
Args
>
size_t
FillLengths
(
size_t
*
lengths
,
const
char
*
a
,
Args
&&
...
args
)
{
return
FillLengths
(
lengths
,
a
)
+
FillLengths
(
lengths
+
1
,
args
...);
}
template
<>
size_t
FillLengths
(
size_t
*
lengths
,
const
char
*
a
)
{
return
*
lengths
=
strlen
(
a
);
}
template
<
typename
...
Args
>
char
*
StringCat
(
char
*
p
,
const
size_t
*
lengths
,
const
char
*
a
,
Args
&&
...
args
)
{
return
StringCat
(
StringCat
(
p
,
lengths
,
a
),
lengths
+
1
,
args
...);
}
template
<>
char
*
StringCat
(
char
*
p
,
const
size_t
*
lengths
,
const
char
*
a
)
{
return
std
::
copy_n
(
a
,
*
lengths
,
p
);
}
#endif
src/util/meson.build
View file @
f8cbba18
util = static_library(
'util',
'Exception.cxx',
'Alloc.cxx',
'UTF8.cxx',
'HexFormat.cxx',
'MimeType.cxx',
...
...
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