Ignore:
Timestamp:
Dec 29, 2008, 8:54:36 AM (12 years ago)
Author:
charles
Message:

(trunk libT) avoid some unnecessary memory fragmentation... for composited objects that have a tr_ptrArray, contain the tr_ptrArray directly rather than a pointer to one allocated elsewhere on the heap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/json.c

    r7404 r7524  
    3030{
    3131    tr_benc *      top;
    32     tr_ptrArray *  stack;
     32    tr_ptrArray    stack;
    3333    char *         key;
    3434};
     
    4040    tr_benc * node = NULL;
    4141
    42     if( tr_ptrArrayEmpty( data->stack ) )
     42    if( tr_ptrArrayEmpty( &data->stack ) )
    4343        parent = NULL;
    4444    else
    45         parent = tr_ptrArrayBack( data->stack );
     45        parent = tr_ptrArrayBack( &data->stack );
    4646
    4747    if( !parent )
     
    7272            node = getNode( data );
    7373            tr_bencInitList( node, 0 );
    74             tr_ptrArrayAppend( data->stack, node );
     74            tr_ptrArrayAppend( &data->stack, node );
    7575            break;
    7676
    7777        case JSON_T_ARRAY_END:
    78             tr_ptrArrayPop( data->stack );
     78            tr_ptrArrayPop( &data->stack );
    7979            break;
    8080
     
    8282            node = getNode( data );
    8383            tr_bencInitDict( node, 0 );
    84             tr_ptrArrayAppend( data->stack, node );
     84            tr_ptrArrayAppend( &data->stack, node );
    8585            break;
    8686
    8787        case JSON_T_OBJECT_END:
    88             tr_ptrArrayPop( data->stack );
     88            tr_ptrArrayPop( &data->stack );
    8989            break;
    9090
     
    149149    data.key = NULL;
    150150    data.top = setme_benc;
    151     data.stack = tr_ptrArrayNew( );
     151    data.stack = TR_PTR_ARRAY_INIT;
    152152
    153153    checker = new_JSON_parser( &config );
     
    162162
    163163    delete_JSON_parser( checker );
    164     tr_ptrArrayFree( data.stack, NULL );
     164    tr_ptrArrayDestruct( &data.stack, NULL );
    165165    return err;
    166166}
Note: See TracChangeset for help on using the changeset viewer.