]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Rewrite a comment that didn't adequately explain the code it was documenting.
authorKevin P. Fleming <kpfleming@digium.com>
Tue, 24 Jul 2012 16:53:39 +0000 (16:53 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Tue, 24 Jul 2012 16:53:39 +0000 (16:53 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@370429 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/frame.c

index 8cc81a84718e237db369e194b237da2b2e70263b..1d569047764f61885f25fa39c351295a53b73503 100644 (file)
@@ -523,13 +523,18 @@ struct ast_frame *ast_frdup(const struct ast_frame *f)
        out->datalen = f->datalen;
        out->samples = f->samples;
        out->delivery = f->delivery;
-       /* Set us as having malloc'd header only, so it will eventually
-          get freed. */
+       /* Even though this new frame was allocated from the heap, we can't mark it
+        * with AST_MALLOCD_HDR, AST_MALLOCD_DATA and AST_MALLOCD_SRC, because that
+        * would cause ast_frfree() to attempt to individually free each of those
+        * under the assumption that they were separately allocated. Since this frame
+        * was allocated in a single allocation, we'll only mark it as if the header
+        * was heap-allocated; this will result in the entire frame being properly freed.
+        */
        out->mallocd = AST_MALLOCD_HDR;
        out->offset = AST_FRIENDLY_OFFSET;
        if (out->datalen) {
                out->data.ptr = buf + sizeof(*out) + AST_FRIENDLY_OFFSET;
-               memcpy(out->data.ptr, f->data.ptr, out->datalen);       
+               memcpy(out->data.ptr, f->data.ptr, out->datalen);
        } else {
                out->data.uint32 = f->data.uint32;
        }