Changeset 560


Ignore:
Timestamp:
Mar 9, 2006, 10:44:54 AM (14 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Changed way temporary buffer of ansi export was handled. Need to do that for other exporters as well.
Location:
libcaca/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/driver_network.c

    r559 r560  
    168168    int size;
    169169    char *to_send = cucul_get_ansi(kk->qq, 0, &size);;
    170     to_send = realloc(to_send, kk->qq->width * kk->qq->height * 15 * 3);
     170 
    171171   
    172172    /* ANSI code for move(0,0)*/
     
    179179        perror("send");
    180180        return;
    181     }
    182    
    183     if(to_send) {
    184         free(to_send);
    185181    }
    186182
  • libcaca/trunk/cucul/cucul.c

    r553 r560  
    7373    }
    7474
     75    qq->ansi_buffer = NULL;
     76   
    7577    return qq;
    7678}
     
    271273    free(qq->attr);
    272274
     275    if(qq->ansi_buffer)
     276        free(qq->ansi_buffer);
     277
    273278    free(qq);
    274279}
  • libcaca/trunk/cucul/cucul_internals.h

    r543 r560  
    4646
    4747    unsigned int refcount;
     48
     49    /* Exporters facilities */
     50    unsigned char *ansi_buffer;
     51
    4852};
    4953
  • libcaca/trunk/cucul/export.c

    r555 r560  
    276276    };
    277277
    278     char *buffer, *cur;
     278    char *cur;
    279279    unsigned int x, y;
    280280
    281281    /* 20 bytes assumed for max length per pixel.
    282282     * Add height*9 to that (zeroes color at the end and jump to next line) */
    283     buffer = malloc(((qq->height*9) + (qq->width * qq->height * 20)) * sizeof(char));
    284     cur = buffer;
     283    if(qq->ansi_buffer)
     284        free(qq->ansi_buffer);
     285    qq->ansi_buffer = malloc(((qq->height*9) + (qq->width * qq->height * 20)) * sizeof(char));
     286    cur = qq->ansi_buffer;
    285287
    286288    // *cur++ = '';
     
    322324
    323325    /* Crop to really used size */
    324     *size = (strlen(buffer) + 1)* sizeof(char);
    325     buffer = realloc(buffer, *size);
    326 
    327     return buffer;
     326    *size = (strlen(qq->ansi_buffer) + 1)* sizeof(char);
     327    qq->ansi_buffer = realloc(qq->ansi_buffer, *size);
     328
     329    return qq->ansi_buffer;
    328330}
    329331
Note: See TracChangeset for help on using the changeset viewer.