Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
2b617e77
Commit
2b617e77
authored
May 24, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inline strdup, strndup, lldiv and getenv
Also fix an overflow in strndup().
parent
c4e0f186
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
77 deletions
+37
-77
include/vlc_common.h
include/vlc_common.h
+0
-13
include/vlc_fixups.h
include/vlc_fixups.h
+37
-4
src/extras/libc.c
src/extras/libc.c
+0
-56
src/libvlccore.sym
src/libvlccore.sym
+0
-4
No files found.
include/vlc_common.h
View file @
2b617e77
...
...
@@ -719,31 +719,18 @@ static inline void _SetQWBE( uint8_t *p, uint64_t i_qw )
#define VLC_UNUSED(x) (void)(x)
/* Stuff defined in src/extras/libc.c */
VLC_EXPORT
(
char
*
,
vlc_strdup
,
(
const
char
*
s
)
);
VLC_EXPORT
(
int
,
vlc_vasprintf
,
(
char
**
,
const
char
*
,
va_list
)
);
VLC_EXPORT
(
int
,
vlc_asprintf
,
(
char
**
,
const
char
*
,
...
)
ATTRIBUTE_FORMAT
(
2
,
3
)
);
VLC_EXPORT
(
char
*
,
vlc_strndup
,
(
const
char
*
s
,
size_t
n
)
);
VLC_EXPORT
(
size_t
,
vlc_strlcpy
,
(
char
*
,
const
char
*
,
size_t
)
);
VLC_EXPORT
(
double
,
vlc_atof
,
(
const
char
*
nptr
)
);
VLC_EXPORT
(
int64_t
,
vlc_atoll
,
(
const
char
*
nptr
)
);
VLC_EXPORT
(
int64_t
,
vlc_strtoll
,
(
const
char
*
nptr
,
char
**
endptr
,
int
base
)
);
VLC_EXPORT
(
size_t
,
vlc_strnlen
,
(
const
char
*
,
size_t
)
);
#if defined(SYS_BEOS) \
|| (defined (__FreeBSD__) && (__FreeBSD__ < 5))
typedef
struct
{
long
long
quot
;
/* Quotient. */
long
long
rem
;
/* Remainder. */
}
lldiv_t
;
#endif
VLC_EXPORT
(
lldiv_t
,
vlc_lldiv
,
(
long
long
numer
,
long
long
denom
)
);
struct
dirent
;
VLC_EXPORT
(
int
,
vlc_scandir
,
(
const
char
*
name
,
struct
dirent
***
namelist
,
int
(
*
filter
)
(
const
struct
dirent
*
),
int
(
*
compar
)
(
const
struct
dirent
**
,
const
struct
dirent
**
)
)
);
VLC_EXPORT
(
int
,
vlc_alphasort
,
(
const
struct
dirent
**
a
,
const
struct
dirent
**
b
)
);
VLC_EXPORT
(
char
*
,
vlc_getenv
,
(
const
char
*
name
)
);
VLC_EXPORT
(
int
,
vlc_strcasecmp
,
(
const
char
*
s1
,
const
char
*
s2
)
);
VLC_EXPORT
(
int
,
vlc_strncasecmp
,
(
const
char
*
s1
,
const
char
*
s2
,
size_t
n
)
);
VLC_EXPORT
(
char
*
,
vlc_strcasestr
,
(
const
char
*
s1
,
const
char
*
s2
)
);
...
...
include/vlc_fixups.h
View file @
2b617e77
...
...
@@ -26,8 +26,17 @@
#ifndef LIBVLC_FIXUPS_H
# define LIBVLC_FIXUPS_H 1
# include <string.h>
# include <stdlib.h>
#ifndef HAVE_STRDUP
# define strdup vlc_strdup
static
inline
char
*
strdup
(
const
char
*
str
)
{
size_t
len
=
strlen
(
str
)
+
1
;
char
*
res
=
malloc
(
len
);
if
(
res
)
memcpy
(
res
,
str
,
len
);
return
res
;
}
#endif
#ifndef HAVE_VASPRINTF
...
...
@@ -39,7 +48,18 @@
#endif
#ifndef HAVE_STRNDUP
# define strndup vlc_strndup
static
inline
char
*
strndup
(
const
char
*
str
,
size_t
max
)
{
const
char
*
end
=
memchr
(
str
,
'\0'
,
max
);
size_t
len
=
end
?
(
size_t
)(
end
-
str
)
:
max
;
char
*
res
=
malloc
(
len
+
1
);
if
(
res
)
{
memcpy
(
res
,
str
,
len
);
res
[
len
]
=
'\0'
;
}
return
res
;
}
#endif
#ifndef HAVE_STRNLEN
...
...
@@ -69,7 +89,16 @@
#endif
#ifndef HAVE_LLDIV
# define lldiv vlc_lldiv
typedef
struct
{
long
long
quot
;
/* Quotient. */
long
long
rem
;
/* Remainder. */
}
lldiv_t
;
static
inline
lldiv_t
lldiv
(
long
long
numer
,
long
long
denom
)
{
lldiv_t
d
=
{
.
quot
=
numer
/
denom
,
.
rem
=
numer
%
denom
};
return
d
;
}
#endif
#ifndef HAVE_SCANDIR
...
...
@@ -78,7 +107,11 @@
#endif
#ifndef HAVE_GETENV
# define getenv vlc_getenv
static
inline
getenv
(
const
char
*
name
)
{
(
void
)
name
;
return
NULL
;
}
#endif
#ifndef HAVE_STRCASECMP
...
...
src/extras/libc.c
View file @
2b617e77
...
...
@@ -74,48 +74,6 @@
# define strcoll strcmp
#endif
/*****************************************************************************
* getenv: just in case, but it should never be called
*****************************************************************************/
#if !defined( HAVE_GETENV )
char
*
vlc_getenv
(
const
char
*
name
)
{
return
NULL
;
}
#endif
/*****************************************************************************
* strdup: returns a malloc'd copy of a string
*****************************************************************************/
#if !defined( HAVE_STRDUP )
char
*
vlc_strdup
(
const
char
*
string
)
{
return
strndup
(
string
,
strlen
(
string
)
);
}
#endif
/*****************************************************************************
* strndup: returns a malloc'd copy of at most n bytes of string
* Does anyone know whether or not it will be present in Jaguar?
*****************************************************************************/
#if !defined( HAVE_STRNDUP )
char
*
vlc_strndup
(
const
char
*
string
,
size_t
n
)
{
char
*
psz
;
size_t
len
=
strlen
(
string
);
len
=
__MIN
(
len
,
n
);
psz
=
(
char
*
)
malloc
(
len
+
1
);
if
(
psz
!=
NULL
)
{
memcpy
(
(
void
*
)
psz
,
(
const
void
*
)
string
,
len
);
psz
[
len
]
=
0
;
}
return
psz
;
}
#endif
/*****************************************************************************
* strnlen:
*****************************************************************************/
...
...
@@ -370,20 +328,6 @@ int64_t vlc_atoll( const char *nptr )
}
#endif
/*****************************************************************************
* lldiv: returns quotient and remainder
*****************************************************************************/
#if !defined( HAVE_LLDIV )
lldiv_t
vlc_lldiv
(
long
long
numer
,
long
long
denom
)
{
lldiv_t
d
;
d
.
quot
=
numer
/
denom
;
d
.
rem
=
numer
%
denom
;
return
d
;
}
#endif
/**
* Copy a string to a sized buffer. The result is always nul-terminated
* (contrary to strncpy()).
...
...
src/libvlccore.sym
View file @
2b617e77
...
...
@@ -401,7 +401,6 @@ vlc_fastmem_register
vlc_freeaddrinfo
vlc_gai_strerror
vlc_getaddrinfo
vlc_getenv
vlc_getnameinfo
vlc_gettext
vlc_iconv
...
...
@@ -410,7 +409,6 @@ vlc_iconv_open
__vlc_list_children
__vlc_list_find
vlc_list_release
vlc_lldiv
vlc_memcpy
vlc_memset
vlc_module_create
...
...
@@ -444,10 +442,8 @@ vlc_sdp_Start
vlc_sendmsg
vlc_strcasecmp
vlc_strcasestr
vlc_strdup
vlc_strlcpy
vlc_strncasecmp
vlc_strndup
vlc_strnlen
vlc_strtoll
vlc_submodule_create
...
...
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