Added braces around single statement blocks.

This commit is contained in:
Svend Sorensen
2005-03-24 12:32:39 +00:00
parent 76988c8ef0
commit 24068b5a61
8 changed files with 113 additions and 65 deletions

View File

@@ -41,10 +41,11 @@ Cdtext *cdtext_init ()
};
new_cdtext = (Cdtext *) calloc (sizeof (cdtext) / sizeof (Cdtext), sizeof (Cdtext));
if (NULL == new_cdtext)
if (NULL == new_cdtext) {
fprintf (stderr, "problem allocating memory\n");
else
} else {
memcpy (new_cdtext, cdtext, sizeof(cdtext));
}
return new_cdtext;
}
@@ -54,8 +55,9 @@ void cdtext_delete (Cdtext *cdtext)
int i;
if (NULL != cdtext) {
for (i = 0; PTI_END != cdtext[i].pti; i++)
for (i = 0; PTI_END != cdtext[i].pti; i++) {
free (cdtext[i].value);
}
free (cdtext);
}
}
@@ -63,9 +65,11 @@ void cdtext_delete (Cdtext *cdtext)
/* return 0 if there is no cdtext, returns non-zero otherwise */
int cdtext_is_empty (Cdtext *cdtext)
{
for (; PTI_END != cdtext->pti; cdtext++)
if (NULL != cdtext->value)
for (; PTI_END != cdtext->pti; cdtext++) {
if (NULL != cdtext->value) {
return -1;
}
}
return 0;
}
@@ -73,20 +77,24 @@ int cdtext_is_empty (Cdtext *cdtext)
/* sets cdtext's pti entry to field */
void cdtext_set (int pti, char *value, Cdtext *cdtext)
{
if (NULL != value) /* don't pass NULL to strdup */
for (; PTI_END != cdtext->pti; cdtext++)
if (NULL != value) { /* don't pass NULL to strdup */
for (; PTI_END != cdtext->pti; cdtext++) {
if (pti == cdtext->pti) {
free (cdtext->value);
cdtext->value = strdup (value);
}
}
}
}
/* returns value for pti, NULL if pti is not found */
char *cdtext_get (int pti, Cdtext *cdtext)
{
for (; PTI_END != cdtext->pti; cdtext++)
if (pti == cdtext->pti)
for (; PTI_END != cdtext->pti; cdtext++) {
if (pti == cdtext->pti) {
return cdtext->value;
}
}
return NULL;
}