Changeset 299


Ignore:
Timestamp:
Jan 1, 2004, 5:29:50 PM (17 years ago)
Author:
Sam Hocevar
Message:
  • examples/cacaview.c: + Use sprintf() instead of snprintf() so that cacaview builds with DJGPP.
  • examples/aafire.c: + bzero the pixel buffer in the initialisation routine.
Location:
libcaca/trunk/examples
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/examples/aafire.c

    r295 r299  
    3030#include <stdio.h>
    3131#include <stdlib.h>
     32#include <string.h>
    3233#include "caca.h"
    3334
     
    134135  caca_set_bitmap_palette(caca_bitmap, r, g, b, a);
    135136  bitmap = malloc(4 * caca_get_width() * caca_get_height() * sizeof(char));
     137  memset(bitmap, 0, 4 * caca_get_width() * caca_get_height());
    136138#else
    137139  aa_hidecursor (context);
  • libcaca/trunk/examples/cacaview.c

    r291 r299  
    228228        if(items && reload)
    229229        {
    230             char *buffer = malloc(ww + 1);
     230            char *buffer;
     231            int len = strlen(" Loading `%s'... ") + strlen(list[current]);
     232
     233            if(len < ww + 1)
     234                len = ww + 1;
     235
     236            buffer = malloc(len);
    231237
    232238            /* Reset image-specific runtime variables */
    233239            zoom = 0;
    234240
    235             snprintf(buffer, ww, " Loading `%s'... ", list[current]);
     241            sprintf(buffer, " Loading `%s'... ", list[current]);
    236242            buffer[ww] = '\0';
    237243            caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE);
     
    262268        else if(!pixels)
    263269        {
    264             char *buffer = malloc(ww + 1);
    265             snprintf(buffer, ww, " Error loading `%s'. ", list[current]);
     270            char *buffer;
     271            int len = strlen(" Error loading `%s'. ") + strlen(list[current]);
     272
     273            if(len < ww + 1)
     274                len = ww + 1;
     275
     276            buffer = malloc(len);
     277
     278            sprintf(buffer, " Error loading `%s'. ", list[current]);
    266279            buffer[ww] = '\0';
    267280            caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE);
     
    323336                        "(zoom: %s%i)", zoom > 0 ? "+" : "", zoom);
    324337
    325             caca_set_color(CACA_COLOR_LIGHTRED, CACA_COLOR_BLACK);
     338            caca_set_color(CACA_COLOR_LIGHTGRAY, CACA_COLOR_BLACK);
    326339            caca_draw_line(0, wh - 1, ww - 1, wh - 1, ' ');
    327340            switch(status)
Note: See TracChangeset for help on using the changeset viewer.