[vlc-commits] dvb: do decode_BCD without asprintf
Ilkka Ollakka
git at videolan.org
Tue Mar 22 14:14:43 CET 2011
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Mon Mar 21 21:31:30 2011 +0200| [9914cd554d1f24bc0149e2ca05b41d227c6e11bf] | committer: Ilkka Ollakka
dvb: do decode_BCD without asprintf
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9914cd554d1f24bc0149e2ca05b41d227c6e11bf
---
modules/access/dvb/scan.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/modules/access/dvb/scan.c b/modules/access/dvb/scan.c
index 7c0c23b..f5e3028 100644
--- a/modules/access/dvb/scan.c
+++ b/modules/access/dvb/scan.c
@@ -150,15 +150,12 @@ static void scan_service_Delete( scan_service_t *p_srv )
static int decode_BCD( uint32_t input, uint32_t *output )
{
- char *psz_decoded="";
- do
+ *output = 0;
+ for( short index=28; index >= 0 ; index -= 4 )
{
- if(asprintf( &psz_decoded, "%1d%1d%s", ( input & 0xf0 ) >> 4, input & 0x0f, psz_decoded ? psz_decoded : "" ) < 0 )
- return VLC_ENOMEM;
- input >>= 8;
- } while( input );
- *output = atol( psz_decoded );
- free( psz_decoded );
+ *output *= 10;
+ *output += ((input >> index) & 0x0f);
+ };
return VLC_SUCCESS;
}
More information about the vlc-commits
mailing list