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
38bf8128
Commit
38bf8128
authored
Jan 03, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: removed unused functions
Removed all allocation functions, xwrite(), xread(), ARRAY_SIZE(). Those have been superseded by GLib.
parent
b42e10b8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
112 deletions
+8
-112
wavpack_plugin.c
src/decoder/wavpack_plugin.c
+2
-0
event_pipe.c
src/event_pipe.c
+3
-0
utils.c
src/utils.c
+3
-55
utils.h
src/utils.h
+0
-57
No files found.
src/decoder/wavpack_plugin.c
View file @
38bf8128
...
...
@@ -27,6 +27,8 @@
#include <assert.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
#define CHUNK_SIZE 1020
...
...
src/event_pipe.c
View file @
38bf8128
...
...
@@ -25,6 +25,9 @@
#include <assert.h>
#include <glib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#ifdef WIN32
/* for _O_BINARY */
...
...
src/utils.c
View file @
38bf8128
...
...
@@ -27,6 +27,7 @@
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#ifndef WIN32
#include <pwd.h>
...
...
@@ -54,55 +55,6 @@ void my_usleep(long usec)
#endif
}
G_GNUC_MALLOC
char
*
xstrdup
(
const
char
*
s
)
{
char
*
ret
=
strdup
(
s
);
if
(
G_UNLIKELY
(
!
ret
))
g_error
(
"OOM: strdup"
);
return
ret
;
}
/* borrowed from git :) */
G_GNUC_MALLOC
void
*
xmalloc
(
size_t
size
)
{
void
*
ret
;
assert
(
G_LIKELY
(
size
));
ret
=
malloc
(
size
);
if
(
G_UNLIKELY
(
!
ret
))
g_error
(
"OOM: malloc"
);
return
ret
;
}
G_GNUC_MALLOC
void
*
xrealloc
(
void
*
ptr
,
size_t
size
)
{
void
*
ret
=
realloc
(
ptr
,
size
);
/* some C libraries return NULL when size == 0,
* make sure we get a free()-able pointer (free(NULL)
* doesn't work with all C libraries, either) */
if
(
G_UNLIKELY
(
!
ret
&&
!
size
))
ret
=
realloc
(
ptr
,
1
);
if
(
G_UNLIKELY
(
!
ret
))
g_error
(
"OOM: realloc"
);
return
ret
;
}
G_GNUC_MALLOC
void
*
xcalloc
(
size_t
nmemb
,
size_t
size
)
{
void
*
ret
;
assert
(
G_LIKELY
(
nmemb
&&
size
));
ret
=
calloc
(
nmemb
,
size
);
if
(
G_UNLIKELY
(
!
ret
))
g_error
(
"OOM: calloc"
);
return
ret
;
}
char
*
parsePath
(
char
*
path
)
{
#ifndef WIN32
...
...
@@ -112,7 +64,6 @@ char *parsePath(char *path)
}
else
if
(
path
[
0
]
==
'~'
)
{
size_t
pos
=
1
;
const
char
*
home
;
char
*
newPath
;
if
(
path
[
1
]
==
'/'
||
path
[
1
]
==
'\0'
)
{
ConfigParam
*
param
=
getConfigParam
(
CONF_USER
);
...
...
@@ -157,13 +108,10 @@ char *parsePath(char *path)
home
=
passwd
->
pw_dir
;
}
newPath
=
xmalloc
(
strlen
(
home
)
+
strlen
(
path
+
pos
)
+
1
);
strcpy
(
newPath
,
home
);
strcat
(
newPath
,
path
+
pos
);
return
newPath
;
return
g_strconcat
(
home
,
path
+
pos
,
NULL
);
}
else
{
#endif
return
x
strdup
(
path
);
return
g_
strdup
(
path
);
#ifndef WIN32
}
#endif
...
...
src/utils.h
View file @
38bf8128
...
...
@@ -19,14 +19,6 @@
#ifndef MPD_UTILS_H
#define MPD_UTILS_H
#include <glib.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#ifndef assert_static
/* Compile time assertion developed by Ralf Holly */
/* http://pera-software.com/articles/compile-time-assertions.pdf */
...
...
@@ -38,55 +30,6 @@
void
my_usleep
(
long
usec
);
/* trivial functions, keep them inlined */
static
inline
void
xclose
(
int
fd
)
{
while
(
close
(
fd
)
&&
errno
==
EINTR
);
}
static
inline
ssize_t
xread
(
int
fd
,
void
*
buf
,
size_t
len
)
{
ssize_t
nr
;
while
(
1
)
{
nr
=
read
(
fd
,
buf
,
len
);
if
((
nr
<
0
)
&&
(
errno
==
EAGAIN
||
errno
==
EINTR
))
continue
;
return
nr
;
}
}
static
inline
ssize_t
xwrite
(
int
fd
,
const
void
*
buf
,
size_t
len
)
{
ssize_t
nr
;
while
(
1
)
{
nr
=
write
(
fd
,
buf
,
len
);
if
((
nr
<
0
)
&&
(
errno
==
EAGAIN
||
errno
==
EINTR
))
continue
;
return
nr
;
}
}
G_GNUC_MALLOC
char
*
xstrdup
(
const
char
*
s
);
G_GNUC_MALLOC
void
*
xmalloc
(
size_t
size
);
G_GNUC_MALLOC
void
*
xrealloc
(
void
*
ptr
,
size_t
size
);
G_GNUC_MALLOC
void
*
xcalloc
(
size_t
nmemb
,
size_t
size
);
/**
* free a const pointer - unfortunately free() expects a non-const
* pointer, for whatever reason
*/
static
inline
void
xfree
(
const
void
*
p
)
{
union
{
const
void
*
in
;
void
*
out
;
}
deconst
=
{
.
in
=
p
};
free
(
deconst
.
out
);
}
char
*
parsePath
(
char
*
path
);
int
set_nonblocking
(
int
fd
);
...
...
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