Skip to content

Commit

Permalink
picture_pool: inline Create() function
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Denis-Courmont committed Jun 26, 2015
1 parent 569df08 commit 5f67e05
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/misc/picture_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,33 +132,24 @@ static picture_t *picture_pool_ClonePicture(picture_pool_t *pool,
return clone;
}

static picture_pool_t *Create(int picture_count)
picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg)
{
picture_pool_t *pool = calloc(1, sizeof(*pool));
if (!pool)
picture_pool_t *pool = malloc(sizeof (*pool));
if (unlikely(pool == NULL))
return NULL;

pool->tick = 1;
pool->picture_count = picture_count;
pool->picture = calloc(pool->picture_count, sizeof(*pool->picture));
if (!pool->picture) {
free(pool->picture);
pool->picture_count = cfg->picture_count;
pool->picture = calloc(pool->picture_count, sizeof (*pool->picture));
if (unlikely(pool->picture == NULL)) {
free(pool);
return NULL;
}
pool->refs = 1;
vlc_mutex_init(&pool->lock);
return pool;
}

picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg)
{
picture_pool_t *pool = Create(cfg->picture_count);
if (!pool)
return NULL;

pool->refs = 1;
pool->pic_lock = cfg->lock;
pool->pic_unlock = cfg->unlock;
vlc_mutex_init(&pool->lock);

for (unsigned i = 0; i < cfg->picture_count; i++) {
picture_t *picture = picture_pool_ClonePicture(pool, cfg->picture[i]);
Expand Down

0 comments on commit 5f67e05

Please sign in to comment.