[DVDnav-discuss] dvdnav_read_cache_clear: use calloc instead of malloc
Jean-Baptiste Kempf
git at videolan.org
Thu Jul 31 02:02:05 CEST 2014
libdvdnav | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Jul 31 01:59:27 2014 +0200| [f12fec53a4782a6bae7473f85e18d8cfa8060589] | committer: Jean-Baptiste Kempf
dvdnav_read_cache_clear: use calloc instead of malloc
> http://git.videolan.org/gitweb.cgi/libdvdnav.git/?a=commit;h=f12fec53a4782a6bae7473f85e18d8cfa8060589
---
src/read_cache.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/read_cache.c b/src/read_cache.c
index d0056c5..1b2862d 100644
--- a/src/read_cache.c
+++ b/src/read_cache.c
@@ -100,23 +100,19 @@ read_cache_t *dvdnav_read_cache_new(dvdnav_t* dvd_self) {
read_cache_t *self;
int i;
- self = (read_cache_t *)malloc(sizeof(read_cache_t));
+ self = (read_cache_t *)calloc(1, sizeof(read_cache_t));
if(!self)
return NULL;
- self->current = 0;
- self->freeing = 0;
- self->dvd_self = dvd_self;
- self->last_sector = 0;
- self->read_ahead_size = READ_AHEAD_SIZE_MIN;
- self->read_ahead_incr = 0;
- pthread_mutex_init(&self->lock, NULL);
- dvdnav_read_cache_clear(self);
- for (i = 0; i < READ_CACHE_CHUNKS; i++) {
- self->chunk[i].cache_buffer = NULL;
- self->chunk[i].usage_count = 0;
- }
+ self->dvd_self = dvd_self;
+ self->read_ahead_size = READ_AHEAD_SIZE_MIN;
+ pthread_mutex_init(&self->lock, NULL);
+ dvdnav_read_cache_clear(self);
+ for (i = 0; i < READ_CACHE_CHUNKS; i++) {
+ self->chunk[i].cache_buffer = NULL;
+ self->chunk[i].usage_count = 0;
+ }
return self;
}
More information about the DVDnav-discuss
mailing list