Commit 09523e12 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

attachment: remove unnecessary alloc

parent b93dcabc
...@@ -54,10 +54,6 @@ vlc_module_end() ...@@ -54,10 +54,6 @@ vlc_module_end()
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
struct access_sys_t {
input_attachment_t *a;
};
static ssize_t Read(access_t *, uint8_t *, size_t); static ssize_t Read(access_t *, uint8_t *, size_t);
static int Seek(access_t *, uint64_t); static int Seek(access_t *, uint64_t);
static int Control(access_t *, int, va_list); static int Control(access_t *, int, va_list);
...@@ -66,7 +62,6 @@ static int Control(access_t *, int, va_list); ...@@ -66,7 +62,6 @@ static int Control(access_t *, int, va_list);
static int Open(vlc_object_t *object) static int Open(vlc_object_t *object)
{ {
access_t *access = (access_t *)object; access_t *access = (access_t *)object;
access_sys_t *sys;
input_thread_t *input = access->p_input; input_thread_t *input = access->p_input;
if (!input) if (!input)
...@@ -82,21 +77,13 @@ static int Open(vlc_object_t *object) ...@@ -82,21 +77,13 @@ static int Open(vlc_object_t *object)
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* */
access->p_sys = sys = malloc(sizeof(*sys));
if (!sys) {
vlc_input_attachment_Delete(a);
return VLC_ENOMEM;
}
sys->a = a;
/* */ /* */
access_InitFields(access); access_InitFields(access);
access->pf_read = Read; access->pf_read = Read;
access->pf_block = NULL; access->pf_block = NULL;
access->pf_control = Control; access->pf_control = Control;
access->pf_seek = Seek; access->pf_seek = Seek;
access->p_sys = (void *)a;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -104,23 +91,22 @@ static int Open(vlc_object_t *object) ...@@ -104,23 +91,22 @@ static int Open(vlc_object_t *object)
static void Close(vlc_object_t *object) static void Close(vlc_object_t *object)
{ {
access_t *access = (access_t *)object; access_t *access = (access_t *)object;
access_sys_t *sys = access->p_sys; input_attachment_t *a = (void *)access->p_sys;
vlc_input_attachment_Delete(sys->a); vlc_input_attachment_Delete(a);
free(sys);
} }
/* */ /* */
static ssize_t Read(access_t *access, uint8_t *buffer, size_t size) static ssize_t Read(access_t *access, uint8_t *buffer, size_t size)
{ {
access_sys_t *sys = access->p_sys; input_attachment_t *a = (void *)access->p_sys;
access->info.b_eof = access->info.i_pos >= (uint64_t)sys->a->i_data; access->info.b_eof = access->info.i_pos >= (uint64_t)a->i_data;
if (access->info.b_eof) if (access->info.b_eof)
return 0; return 0;
const size_t copy = __MIN(size, sys->a->i_data - access->info.i_pos); const size_t copy = __MIN(size, a->i_data - access->info.i_pos);
memcpy(buffer, (uint8_t*)sys->a->p_data + access->info.i_pos, copy); memcpy(buffer, (uint8_t *)a->p_data + access->info.i_pos, copy);
access->info.i_pos += copy; access->info.i_pos += copy;
return copy; return copy;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment