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
540c7613
Commit
540c7613
authored
Mar 19, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize the localtime_r replacement
parent
48d8e6bf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
50 deletions
+15
-50
include/vlc_fixups.h
include/vlc_fixups.h
+15
-0
modules/access_filter/dump.c
modules/access_filter/dump.c
+0
-20
modules/access_filter/record.c
modules/access_filter/record.c
+0
-9
src/input/vlm.c
src/input/vlm.c
+0
-12
src/text/strings.c
src/text/strings.c
+0
-9
No files found.
include/vlc_fixups.h
View file @
540c7613
...
...
@@ -103,3 +103,18 @@
# endif
#endif
#ifndef HAVE_LOCALTIME_R
/* If localtime_r() is not provided, we assume localtime() uses
* thread-specific storage. */
# include <time.h>
static
struct
tm
*
localtime_r
(
const
time_t
*
timep
,
struct
tm
*
result
)
{
struct
tm
*
s
=
localtime
(
timep
);
if
(
s
==
NULL
)
return
NULL
;
*
result
=
*
s
;
return
result
;
}
#endif
modules/access_filter/dump.c
View file @
540c7613
...
...
@@ -244,26 +244,6 @@ static int Seek (access_t *access, int64_t offset)
return
ret
;
}
#ifndef HAVE_LOCALTIME_R
static
inline
struct
tm
*
localtime_r
(
const
time_t
*
now
,
struct
tm
*
res
)
{
struct
tm
*
unsafe
=
localtime
(
now
);
/*
* This is not thread-safe. Blame your C library.
* On Win32 there SHOULD be _localtime_s instead, but of course
* Cygwin and Mingw32 don't know about it. You're on your own if you
* use this platform.
*/
if
(
unsafe
==
NULL
)
return
NULL
;
memcpy
(
res
,
unsafe
,
sizeof
(
*
res
));
return
res
;
}
#endif
static
void
Trigger
(
access_t
*
access
)
{
access_sys_t
*
p_sys
=
access
->
p_sys
;
...
...
modules/access_filter/record.c
View file @
540c7613
...
...
@@ -367,16 +367,7 @@ static void Dump( access_t *p_access, uint8_t *p_buffer, int i_buffer )
time_t
t
=
time
(
NULL
);
struct
tm
l
;
#ifdef HAVE_LOCALTIME_R
if
(
!
localtime_r
(
&
t
,
&
l
)
)
memset
(
&
l
,
0
,
sizeof
(
l
)
);
#else
/* Grrr */
{
struct
tm
*
p_l
=
localtime
(
&
t
);
if
(
p_l
)
l
=
*
p_l
;
else
memset
(
&
l
,
0
,
sizeof
(
l
)
);
}
#endif
p_input
=
vlc_object_find
(
p_access
,
VLC_OBJECT_INPUT
,
FIND_PARENT
);
if
(
p_input
)
...
...
src/input/vlm.c
View file @
540c7613
...
...
@@ -1536,13 +1536,7 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_sys_t *media,
time_t
i_time
=
(
time_t
)(
schedule
->
i_date
/
1000000
);
char
*
psz_date
;
#ifdef HAVE_LOCALTIME_R
localtime_r
(
&
i_time
,
&
date
);
#else
struct
tm
*
p_date
=
localtime
(
&
i_time
);
date
=
*
p_date
;
#endif
asprintf
(
&
psz_date
,
"%d/%d/%d-%d:%d:%d"
,
date
.
tm_year
+
1900
,
date
.
tm_mon
+
1
,
date
.
tm_mday
,
date
.
tm_hour
,
date
.
tm_min
,
date
.
tm_sec
);
...
...
@@ -1891,13 +1885,7 @@ static char *Save( vlm_t *vlm )
struct
tm
date
;
time_t
i_time
=
(
time_t
)
(
schedule
->
i_date
/
1000000
);
#ifdef HAVE_LOCALTIME_R
localtime_r
(
&
i_time
,
&
date
);
#else
struct
tm
*
p_date
=
localtime
(
&
i_time
);
date
=
*
p_date
;
#endif
p
+=
sprintf
(
p
,
"new %s schedule "
,
schedule
->
psz_name
);
if
(
schedule
->
b_enabled
==
VLC_TRUE
)
...
...
src/text/strings.c
View file @
540c7613
...
...
@@ -618,23 +618,14 @@ char *str_format_time( const char *tformat )
{
char
buffer
[
255
];
time_t
curtime
;
#if defined(HAVE_LOCALTIME_R)
struct
tm
loctime
;
#else
struct
tm
*
loctime
;
#endif
/* Get the current time. */
curtime
=
time
(
NULL
);
/* Convert it to local time representation. */
#if defined(HAVE_LOCALTIME_R)
localtime_r
(
&
curtime
,
&
loctime
);
strftime
(
buffer
,
255
,
tformat
,
&
loctime
);
#else
loctime
=
localtime
(
&
curtime
);
strftime
(
buffer
,
255
,
tformat
,
loctime
);
#endif
return
strdup
(
buffer
);
}
...
...
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