[Asterisk-cvs] asterisk frame.c,1.29,1.30
citats at lists.digium.com
citats at lists.digium.com
Wed Apr 28 13:47:31 CDT 2004
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/home/citats/cvs/asterisk
Modified Files:
frame.c
Log Message:
ast_frdup optimization: only call strlen once and save the result
Index: frame.c
===================================================================
RCS file: /usr/cvsroot/asterisk/frame.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- frame.c 22 Apr 2004 03:02:27 -0000 1.29
+++ frame.c 28 Apr 2004 17:54:01 -0000 1.30
@@ -282,13 +282,15 @@
struct ast_frame *ast_frdup(struct ast_frame *f)
{
struct ast_frame *out;
- int len;
+ int len, srclen = 0;
void *buf;
/* Start with standard stuff */
len = sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + f->datalen;
/* If we have a source, add space for it */
- if (f->src && strlen(f->src))
- len += strlen(f->src) + 1;
+ if (f->src)
+ srclen = strlen(f->src);
+ if (srclen > 0)
+ len += srclen + 1;
buf = malloc(len);
if (!buf)
return NULL;
@@ -303,7 +305,7 @@
out->mallocd = AST_MALLOCD_HDR;
out->offset = AST_FRIENDLY_OFFSET;
out->data = buf + sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET;
- if (f->src && strlen(f->src)) {
+ if (srclen > 0) {
out->src = out->data + f->datalen;
/* Must have space since we allocated for it */
strcpy(out->src, f->src);
More information about the svn-commits
mailing list