diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-04-06 03:43:59 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-04-06 03:43:59 +0000 |
commit | 6d61220e72fd4add3b509dd4d65d59a83158e388 (patch) | |
tree | c764900469821573ff1e56b42e164a1d683f60bf /rtp.c | |
parent | 7d0fc1f19a87e339377b0e7c2d59cc7c099c98cb (diff) |
use more efficient code to produce non-codec-capability list (bug #3960)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5421 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'rtp.c')
-rwxr-xr-x | rtp.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -853,21 +853,35 @@ char* ast_rtp_lookup_mime_subtype(const int isAstFormat, const int code) { char *ast_rtp_lookup_mime_multiple(char *buf, int size, const int capability, const int isAstFormat) { int format; + unsigned len; + char *end = buf; + char *start = buf; if (!buf || !size) return NULL; - snprintf(buf, size, "0x%x (", capability); + snprintf(end, size, "0x%x (", capability); + + len = strlen(end); + end += len; + size -= len; + start = end; for (format = 1; format < AST_RTP_MAX; format <<= 1) { if (capability & format) { const char *name = ast_rtp_lookup_mime_subtype(isAstFormat, format); - snprintf(buf + strlen(buf), size - strlen(buf), "%s|", name); + snprintf(end, size, "%s|", name); + len = strlen(end); + end += len; + size -= len; } } - if (!ast_strlen_zero(buf)) - buf[strlen(buf)] = ')'; + if (start == end) + snprintf(start, size, "nothing)"); + else if (size > 1) + *(end -1) = ')'; + return buf; } |