Changeset 193

Show
Ignore:
Timestamp:
11/27/07 12:49:12 (9 months ago)
Author:
sip
Message:

Static frame allocation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • app_h324m/app_h324m.c

    r192 r193  
    126126        unsigned char buffer[1500]; 
    127127        unsigned int bufferLength; 
     128        unsigned char frame[sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + 1500]; 
    128129}; 
    129130 
     
    142143        unsigned int framelength = FrameGetLength(frame); 
    143144 
     145        /* Get frame */ 
     146        send = (struct ast_frame *) vt->frame;; 
     147 
     148        /* Clear */ 
     149        memset(send,0,sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + 1500); 
     150 
     151        /* Set data */ 
     152        send->data = (unsigned char*)send + AST_FRIENDLY_OFFSET; 
     153        data = send->data; 
     154 
    144155        /* Depending on the type */ 
    145156        switch(FrameGetType(frame)) 
     
    168179                                return NULL; 
    169180 
    170                         /* Create frame */ 
    171                         send = (struct ast_frame *) malloc(sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + framelength + 3); 
    172                         /* Set data*/ 
    173                         send->data = (void*)send + AST_FRIENDLY_OFFSET; 
     181                        /* Set data len*/ 
    174182                        send->datalen = framelength + 1; /* +1 because the the octet with the CMR */ 
    175                         data = send->data; 
     183 
    176184                        /* Set header cmr */ 
    177185                        data[0] = 0xF0; 
     
    211219                        send->delivery.tv_usec = 0; 
    212220                        send->delivery.tv_sec = 0; 
    213                         send->mallocd = AST_MALLOCD_HDR; 
     221                        /* Don't free */ 
     222                        send->mallocd = 0; 
    214223                        /* Send */ 
    215224                        return send; 
     
    254263                                mark = 0; 
    255264                        } 
    256  
    257                         /* Create frame */ 
    258                         send = (struct ast_frame *) malloc(sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + 2 + len); 
    259  
    260                         /* Set data*/ 
    261                         send->data = (unsigned char*)send + AST_FRIENDLY_OFFSET; 
    262                         data = send->data; 
    263265                                 
    264266                        /* if its first pcaket of a frame */ 
     
    324326                        send->delivery.tv_usec = 0; 
    325327                        send->delivery.tv_sec = 0; 
    326                         send->mallocd = AST_MALLOCD_HDR; 
     328                        /* Don't free */ 
     329                        send->mallocd = 0; 
    327330 
    328331                        /* If the next packet is from a different frame */ 
     
    782785                                                ast_write(pseudo,send); 
    783786                                                /* Free frame */ 
    784                                                 ast_frfree(send); 
     787                                                free(send); 
    785788                                        } 
    786789                                        /* Delete frame */ 
Copyright 2006 - Sergio García Murillo
Powered by Trac - Edgewall Software