[vlc-commits] DTV: remove useless reference counter
Rémi Denis-Courmont
git at videolan.org
Sun Mar 20 13:59:17 CET 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Mar 20 14:59:07 2011 +0200| [9144bc1147dc7d989d8c9849735811dec3217d39] | committer: Rémi Denis-Courmont
DTV: remove useless reference counter
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9144bc1147dc7d989d8c9849735811dec3217d39
---
modules/access/dtv/access.c | 56 +-----------------------------------------
1 files changed, 2 insertions(+), 54 deletions(-)
diff --git a/modules/access/dtv/access.c b/modules/access/dtv/access.c
index 72adc94..893ff80 100644
--- a/modules/access/dtv/access.c
+++ b/modules/access/dtv/access.c
@@ -240,17 +240,9 @@ vlc_module_begin ()
#endif
vlc_module_end ()
-typedef struct
-{
- uint16_t pid;
- uint16_t refs;
-} pid_ref_t;
-
struct access_sys_t
{
dvb_device_t *dev;
- pid_ref_t *refv;
- size_t refc;
};
struct delsys
@@ -317,8 +309,6 @@ static int Open (vlc_object_t *obj)
}
sys->dev = dev;
- sys->refv = NULL;
- sys->refc = 0;
access->p_sys = sys;
if (freq != 0)
@@ -356,7 +346,6 @@ static void Close (vlc_object_t *obj)
access_t *access = (access_t *)obj;
access_sys_t *sys = access->p_sys;
- free (sys->refv);
dvb_close (sys->dev);
free (sys);
}
@@ -383,44 +372,6 @@ static block_t *Read (access_t *access)
return block;
}
-/* A PID can be enabled multiple times by the demux, but packets must not be
- * duplicated, so we need to do some reference counting. */
-static int pid_ref (access_sys_t *sys, uint16_t pid)
-{
- pid_ref_t *tab = sys->refv;
- size_t n = sys->refc;
-
- for (size_t i = 0; i < n; i++)
- {
- if (tab[i].pid == pid)
- return ++tab[i].refs;
- }
-
- tab = realloc (tab, (n + 1) * sizeof (*tab));
- if (unlikely(tab == NULL))
- return -1;
-
- tab[n].pid = pid;
- tab[n].refs = 1;
- sys->refv = tab;
- sys->refc = n;
- return 0;
-}
-
-static int pid_unref (access_sys_t *sys, uint16_t pid)
-{
- pid_ref_t *tab = sys->refv;
- size_t n = sys->refc;
-
- /* FIXME? bound memory leak (worst case 32kb) until Close() */
- for (size_t i = 0; i < n; i++)
- {
- if (tab[i].pid == pid)
- return --tab[i].refs;
- }
- return -1;
-}
-
static int Control (access_t *access, int query, va_list args)
{
access_sys_t *sys = access->p_sys;
@@ -475,14 +426,11 @@ static int Control (access_t *access, int query, va_list args)
return VLC_EGENERIC;
if (add)
{
- if (pid_ref (sys, pid) == 0 && dvb_add_pid (dev, pid))
+ if (dvb_add_pid (dev, pid))
return VLC_EGENERIC;
}
else
- {
- if (pid_unref (sys, pid) == 0)
- dvb_remove_pid (sys->dev, pid);
- }
+ dvb_remove_pid (dev, pid);
return VLC_SUCCESS;
}
More information about the vlc-commits
mailing list