예제 #1
0
/**
 * playlist_init:
 * @path            	   : Path to playlist contents file.
 * @size                : Maximum capacity of playlist size.
 *
 * Creates and initializes a playlist.
 *
 * Returns: handle to new playlist if successful, otherwise NULL
 **/
playlist_t *playlist_init(const char *path, size_t size)
{
   struct playlist_entry *entries = NULL;
   playlist_t           *playlist = (playlist_t*)calloc(1, sizeof(*playlist));
   if (!playlist)
      return NULL;

   entries = (struct playlist_entry*)calloc(size, sizeof(*entries));
   if (!entries)
   {
      free(playlist);
      return NULL;
   }

   playlist->entries   = entries;
   playlist->cap       = size;

   playlist_read_file(playlist, path);

   playlist->conf_path = strdup(path);
   return playlist;
}
예제 #2
0
/**
 * playlist_init:
 * @path            	   : Path to playlist contents file.
 * @size                : Maximum capacity of playlist size.
 *
 * Creates and initializes a playlist.
 *
 * Returns: handle to new playlist if successful, otherwise NULL
 **/
playlist_t *playlist_init(const char *path, size_t size)
{
   playlist_t *playlist = (playlist_t*)
      calloc(1, sizeof(*playlist));
   if (!playlist)
      return NULL;

   playlist->entries = (struct playlist_entry*)calloc(size,
         sizeof(*playlist->entries));
   if (!playlist->entries)
      goto error;

   playlist->cap = size;

   playlist_read_file(playlist, path);

   playlist->conf_path = strdup(path);
   return playlist;

error:
   playlist_free(playlist);
   return NULL;
}