1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-12-04 14:46:31 -05:00

Cosmetic changes; no functional change. Use the calloc()-style API correctly.

git-svn-id: https://svn.xiph.org/trunk/ezstream@13304 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
moritz 2007-07-24 15:29:16 +00:00
parent 452a8e83cb
commit c1ca736734
2 changed files with 37 additions and 37 deletions

View File

@ -249,12 +249,12 @@ buildCommandString(const char *extension, const char *fileName,
return (NULL); return (NULL);
} }
newDecoderLen = strlen(decoder) + strlen(fileName) + 1; newDecoderLen = strlen(decoder) + strlen(fileName) + 1;
newDecoder = xcalloc(1, newDecoderLen); newDecoder = xcalloc(newDecoderLen, sizeof(char));
replaceString(decoder, newDecoder, newDecoderLen, TRACK_PLACEHOLDER, replaceString(decoder, newDecoder, newDecoderLen, TRACK_PLACEHOLDER,
fileName); fileName);
if (strstr(decoder, ARTIST_PLACEHOLDER) != NULL) { if (strstr(decoder, ARTIST_PLACEHOLDER) != NULL) {
size_t tmpLen = strlen(newDecoder) + strlen(metadata_get_artist(mdata)) + 1; size_t tmpLen = strlen(newDecoder) + strlen(metadata_get_artist(mdata)) + 1;
char *tmpStr = xcalloc(1, tmpLen); char *tmpStr = xcalloc(tmpLen, sizeof(char));
replaceString(newDecoder, tmpStr, tmpLen, ARTIST_PLACEHOLDER, replaceString(newDecoder, tmpStr, tmpLen, ARTIST_PLACEHOLDER,
metadata_get_artist(mdata)); metadata_get_artist(mdata));
xfree(newDecoder); xfree(newDecoder);
@ -262,7 +262,7 @@ buildCommandString(const char *extension, const char *fileName,
} }
if (strstr(decoder, TITLE_PLACEHOLDER) != NULL) { if (strstr(decoder, TITLE_PLACEHOLDER) != NULL) {
size_t tmpLen = strlen(newDecoder) + strlen(metadata_get_title(mdata)) + 1; size_t tmpLen = strlen(newDecoder) + strlen(metadata_get_title(mdata)) + 1;
char *tmpStr = xcalloc(1, tmpLen); char *tmpStr = xcalloc(tmpLen, sizeof(char));
replaceString(newDecoder, tmpStr, tmpLen, TITLE_PLACEHOLDER, replaceString(newDecoder, tmpStr, tmpLen, TITLE_PLACEHOLDER,
metadata_get_title(mdata)); metadata_get_title(mdata));
xfree(newDecoder); xfree(newDecoder);
@ -282,7 +282,7 @@ buildCommandString(const char *extension, const char *fileName,
if (metadataFromProgram && pezConfig->metadataFormat != NULL) { if (metadataFromProgram && pezConfig->metadataFormat != NULL) {
char *mdataString = getMetadataString(pezConfig->metadataFormat, mdata); char *mdataString = getMetadataString(pezConfig->metadataFormat, mdata);
size_t tmpLen = strlen(newDecoder) + strlen(mdataString) + 1; size_t tmpLen = strlen(newDecoder) + strlen(mdataString) + 1;
char *tmpStr = xcalloc(1, tmpLen); char *tmpStr = xcalloc(tmpLen, sizeof(char));
replaceString(newDecoder, tmpStr, tmpLen, replaceString(newDecoder, tmpStr, tmpLen,
METADATA_PLACEHOLDER, mdataString); METADATA_PLACEHOLDER, mdataString);
xfree(newDecoder); xfree(newDecoder);
@ -291,14 +291,14 @@ buildCommandString(const char *extension, const char *fileName,
} else { } else {
if (!metadataFromProgram && strstr(decoder, TITLE_PLACEHOLDER) != NULL) { if (!metadataFromProgram && strstr(decoder, TITLE_PLACEHOLDER) != NULL) {
size_t tmpLen = strlen(newDecoder) + 1; size_t tmpLen = strlen(newDecoder) + 1;
char *tmpStr = xcalloc(1, tmpLen); char *tmpStr = xcalloc(tmpLen, sizeof(char));
replaceString(newDecoder, tmpStr, tmpLen, replaceString(newDecoder, tmpStr, tmpLen,
METADATA_PLACEHOLDER, ""); METADATA_PLACEHOLDER, "");
xfree(newDecoder); xfree(newDecoder);
newDecoder = tmpStr; newDecoder = tmpStr;
} else { } else {
size_t tmpLen = strlen(newDecoder) + strlen(metadata_get_string(mdata)) + 1; size_t tmpLen = strlen(newDecoder) + strlen(metadata_get_string(mdata)) + 1;
char *tmpStr = xcalloc(1, tmpLen); char *tmpStr = xcalloc(tmpLen, sizeof(char));
replaceString(newDecoder, tmpStr, tmpLen, replaceString(newDecoder, tmpStr, tmpLen,
METADATA_PLACEHOLDER, METADATA_PLACEHOLDER,
metadata_get_string(mdata)); metadata_get_string(mdata));
@ -316,7 +316,7 @@ buildCommandString(const char *extension, const char *fileName,
(strcmp(pezConfig->format, THEORA_FORMAT) != 0) ? " (unsupported) " : " ", (strcmp(pezConfig->format, THEORA_FORMAT) != 0) ? " (unsupported) " : " ",
pezConfig->format); pezConfig->format);
commandStringLen = strlen(newDecoder) + 1; commandStringLen = strlen(newDecoder) + 1;
commandString = xcalloc(1, commandStringLen); commandString = xcalloc(commandStringLen, sizeof(char));
strlcpy(commandString, newDecoder, commandStringLen); strlcpy(commandString, newDecoder, commandStringLen);
xfree(decoder); xfree(decoder);
xfree(encoder); xfree(encoder);
@ -325,12 +325,12 @@ buildCommandString(const char *extension, const char *fileName,
} }
newEncoderLen = strlen(encoder) + strlen(metadata_get_artist(mdata)) + 1; newEncoderLen = strlen(encoder) + strlen(metadata_get_artist(mdata)) + 1;
newEncoder = xcalloc(1, newEncoderLen); newEncoder = xcalloc(newEncoderLen, sizeof(char));
replaceString(encoder, newEncoder, newEncoderLen, ARTIST_PLACEHOLDER, replaceString(encoder, newEncoder, newEncoderLen, ARTIST_PLACEHOLDER,
metadata_get_artist(mdata)); metadata_get_artist(mdata));
if (strstr(encoder, TITLE_PLACEHOLDER) != NULL) { if (strstr(encoder, TITLE_PLACEHOLDER) != NULL) {
size_t tmpLen = strlen(newEncoder) + strlen(metadata_get_title(mdata)) + 1; size_t tmpLen = strlen(newEncoder) + strlen(metadata_get_title(mdata)) + 1;
char *tmpStr = xcalloc(1, tmpLen); char *tmpStr = xcalloc(tmpLen, sizeof(char));
replaceString(newEncoder, tmpStr, tmpLen, TITLE_PLACEHOLDER, replaceString(newEncoder, tmpStr, tmpLen, TITLE_PLACEHOLDER,
metadata_get_title(mdata)); metadata_get_title(mdata));
xfree(newEncoder); xfree(newEncoder);
@ -340,7 +340,7 @@ buildCommandString(const char *extension, const char *fileName,
if (metadataFromProgram && pezConfig->metadataFormat != NULL) { if (metadataFromProgram && pezConfig->metadataFormat != NULL) {
char *mdataString = getMetadataString(pezConfig->metadataFormat, mdata); char *mdataString = getMetadataString(pezConfig->metadataFormat, mdata);
size_t tmpLen = strlen(newEncoder) + strlen(mdataString) + 1; size_t tmpLen = strlen(newEncoder) + strlen(mdataString) + 1;
char *tmpStr = xcalloc(1, tmpLen); char *tmpStr = xcalloc(tmpLen, sizeof(char));
replaceString(newEncoder, tmpStr, tmpLen, replaceString(newEncoder, tmpStr, tmpLen,
METADATA_PLACEHOLDER, mdataString); METADATA_PLACEHOLDER, mdataString);
xfree(newEncoder); xfree(newEncoder);
@ -349,14 +349,14 @@ buildCommandString(const char *extension, const char *fileName,
} else { } else {
if (!metadataFromProgram && strstr(encoder, TITLE_PLACEHOLDER) != NULL) { if (!metadataFromProgram && strstr(encoder, TITLE_PLACEHOLDER) != NULL) {
size_t tmpLen = strlen(newEncoder) + 1; size_t tmpLen = strlen(newEncoder) + 1;
char *tmpStr = xcalloc(1, tmpLen); char *tmpStr = xcalloc(tmpLen, sizeof(char));
replaceString(newEncoder, tmpStr, tmpLen, replaceString(newEncoder, tmpStr, tmpLen,
METADATA_PLACEHOLDER, ""); METADATA_PLACEHOLDER, "");
xfree(newEncoder); xfree(newEncoder);
newEncoder = tmpStr; newEncoder = tmpStr;
} else { } else {
size_t tmpLen = strlen(newEncoder) + strlen(metadata_get_string(mdata)) + 1; size_t tmpLen = strlen(newEncoder) + strlen(metadata_get_string(mdata)) + 1;
char *tmpStr = xcalloc(1, tmpLen); char *tmpStr = xcalloc(tmpLen, sizeof(char));
replaceString(newEncoder, tmpStr, tmpLen, replaceString(newEncoder, tmpStr, tmpLen,
METADATA_PLACEHOLDER, METADATA_PLACEHOLDER,
metadata_get_string(mdata)); metadata_get_string(mdata));
@ -368,7 +368,7 @@ buildCommandString(const char *extension, const char *fileName,
commandStringLen = strlen(newDecoder) + strlen(" | ") + commandStringLen = strlen(newDecoder) + strlen(" | ") +
strlen(newEncoder) + 1; strlen(newEncoder) + 1;
commandString = xcalloc(1, commandStringLen); commandString = xcalloc(commandStringLen, sizeof(char));
snprintf(commandString, commandStringLen, "%s | %s", newDecoder, snprintf(commandString, commandStringLen, "%s | %s", newDecoder,
newEncoder); newEncoder);
@ -384,7 +384,7 @@ char *
getMetadataString(const char *format, metadata_t *mdata) getMetadataString(const char *format, metadata_t *mdata)
{ {
char *tmp, *str; char *tmp, *str;
size_t siz; size_t len;
if (mdata == NULL) { if (mdata == NULL) {
printf("%s: getMetadataString(): Internal error: NULL metadata_t\n", printf("%s: getMetadataString(): Internal error: NULL metadata_t\n",
@ -398,33 +398,33 @@ getMetadataString(const char *format, metadata_t *mdata)
str = xstrdup(format); str = xstrdup(format);
if (strstr(format, ARTIST_PLACEHOLDER) != NULL) { if (strstr(format, ARTIST_PLACEHOLDER) != NULL) {
siz = strlen(str) + strlen(metadata_get_artist(mdata)) + 1; len = strlen(str) + strlen(metadata_get_artist(mdata)) + 1;
tmp = xcalloc(1, siz); tmp = xcalloc(len, sizeof(char));
replaceString(str, tmp, siz, ARTIST_PLACEHOLDER, replaceString(str, tmp, len, ARTIST_PLACEHOLDER,
metadata_get_artist(mdata)); metadata_get_artist(mdata));
xfree(str); xfree(str);
str = tmp; str = tmp;
} }
if (strstr(format, TITLE_PLACEHOLDER) != NULL) { if (strstr(format, TITLE_PLACEHOLDER) != NULL) {
siz = strlen(str) + strlen(metadata_get_title(mdata)) + 1; len = strlen(str) + strlen(metadata_get_title(mdata)) + 1;
tmp = xcalloc(1, siz); tmp = xcalloc(len, sizeof(char));
replaceString(str, tmp, siz, TITLE_PLACEHOLDER, replaceString(str, tmp, len, TITLE_PLACEHOLDER,
metadata_get_title(mdata)); metadata_get_title(mdata));
xfree(str); xfree(str);
str = tmp; str = tmp;
} }
if (strstr(format, STRING_PLACEHOLDER) != NULL) { if (strstr(format, STRING_PLACEHOLDER) != NULL) {
siz = strlen(str) + strlen(metadata_get_string(mdata)) + 1; len = strlen(str) + strlen(metadata_get_string(mdata)) + 1;
tmp = xcalloc(1, siz); tmp = xcalloc(len, sizeof(char));
replaceString(str, tmp, siz, STRING_PLACEHOLDER, replaceString(str, tmp, len, STRING_PLACEHOLDER,
metadata_get_string(mdata)); metadata_get_string(mdata));
xfree(str); xfree(str);
str = tmp; str = tmp;
} }
if (strstr(format, TRACK_PLACEHOLDER) != NULL) { if (strstr(format, TRACK_PLACEHOLDER) != NULL) {
siz = strlen(str) + strlen(metadata_get_filename(mdata)) + 1; len = strlen(str) + strlen(metadata_get_filename(mdata)) + 1;
tmp = xcalloc(1, siz); tmp = xcalloc(len, sizeof(char));
replaceString(str, tmp, siz, TRACK_PLACEHOLDER, replaceString(str, tmp, len, TRACK_PLACEHOLDER,
metadata_get_filename(mdata)); metadata_get_filename(mdata));
xfree(str); xfree(str);
str = tmp; str = tmp;

View File

@ -629,7 +629,7 @@ metadata_get_length(metadata_t *md)
char * char *
metadata_assemble_string(metadata_t *md) metadata_assemble_string(metadata_t *md)
{ {
size_t siz; size_t len;
char *str; char *str;
if (md == NULL) { if (md == NULL) {
@ -641,23 +641,23 @@ metadata_assemble_string(metadata_t *md)
if (md->artist == NULL && md->title == NULL && md->program == 0) if (md->artist == NULL && md->title == NULL && md->program == 0)
return (metadata_get_name(md->filename)); return (metadata_get_name(md->filename));
siz = 0; len = 0;
if (md->artist != NULL) if (md->artist != NULL)
siz += strlen(md->artist); len += strlen(md->artist);
if (md->title != NULL) { if (md->title != NULL) {
if (siz > 0) if (len > 0)
siz += strlen(" - "); len += strlen(" - ");
siz += strlen(md->title); len += strlen(md->title);
} }
siz++; len++;
str = xcalloc(1, siz); str = xcalloc(len, sizeof(char));
if (md->artist != NULL) if (md->artist != NULL)
strlcpy(str, md->artist, siz); strlcpy(str, md->artist, len);
if (md->title != NULL) { if (md->title != NULL) {
if (md->artist != NULL) if (md->artist != NULL)
strlcat(str, " - ", siz); strlcat(str, " - ", len);
strlcat(str, md->title, siz); strlcat(str, md->title, len);
} }
return (str); return (str);