From Burkhard Plaum:

1. Fix a crash, which happened when cdtext_get() was called for an emtp=
y
   (i.e. NULL) field.

2. Add another function cdtext_get_const(), which returns a const point=
er
   and avoids too much strcpying (apps may want only to TEST if a
   field is present or have their own string management routines).
This commit is contained in:
rocky
2005-04-25 23:06:21 +00:00
parent 320c9bd55f
commit adc1418cbd
3 changed files with 23 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: cdtext.c,v 1.4 2005/03/23 11:15:25 rocky Exp $
$Id: cdtext.c,v 1.5 2005/04/25 23:06:21 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
toc reading routine adapted from cuetools
@@ -89,10 +89,18 @@ cdtext_destroy (cdtext_t *p_cdtext)
char *
cdtext_get (cdtext_field_t key, const cdtext_t *p_cdtext)
{
if (key == CDTEXT_INVALID) return NULL;
if ((key == CDTEXT_INVALID) || (!p_cdtext->field[key])) return NULL;
return strdup(p_cdtext->field[key]);
}
const char *
cdtext_get_const (cdtext_field_t key, const cdtext_t *p_cdtext)
{
if (key == CDTEXT_INVALID) return NULL;
return p_cdtext->field[key];
}
/*! Initialize a new cdtext structure.
When the structure is no longer needed, release the
resources using cdtext_delete.