Ignore:
Timestamp:
Apr 19, 2008, 9:25:52 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Remove all unsigned ints from exported functions. Signed arithmetic is far better for error checking.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/font.c

    r2303 r2305  
    7171#define DECLARE_UNPACKGLYPH(bpp) \
    7272    static inline void \
    73       unpack_glyph ## bpp(uint8_t *glyph, uint8_t *packed_data, \
    74                           unsigned int n) \
     73      unpack_glyph ## bpp(uint8_t *glyph, uint8_t *packed_data, int n) \
    7574{ \
    76     unsigned int i; \
     75    int i; \
    7776    \
    7877    for(i = 0; i < n; i++) \
     
    112111 *  \return A font handle or NULL in case of error.
    113112 */
    114 cucul_font_t *cucul_load_font(void const *data, unsigned int size)
     113cucul_font_t *cucul_load_font(void const *data, size_t size)
    115114{
    116115    cucul_font_t *f;
    117     unsigned int i;
     116    int i;
    118117
    119118    if(size == 0)
     
    248247                + f->header.blocks * sizeof(struct block_info),
    249248           f->header.glyphs * sizeof(struct glyph_info));
    250     for(i = 0; i < f->header.glyphs; i++)
     249    for(i = 0; i < (int)f->header.glyphs; i++)
    251250    {
    252251        f->glyph_list[i].width = hton16(f->glyph_list[i].width);
     
    325324 *  \return The standard glyph width.
    326325 */
    327 unsigned int cucul_get_font_width(cucul_font_t const *f)
     326int cucul_get_font_width(cucul_font_t const *f)
    328327{
    329328    return f->header.width;
     
    340339 *  \return The standard glyph height.
    341340 */
    342 unsigned int cucul_get_font_height(cucul_font_t const *f)
     341int cucul_get_font_height(cucul_font_t const *f)
    343342{
    344343    return f->header.height;
     
    405404 *  all. They may be cropped instead in future versions.
    406405 *
    407  *  This function never fails.
     406 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     407 *  - \c EINVAL Specified width, height or pitch is invalid.
    408408 *
    409409 *  \param cv The canvas to render
     
    413413 *  \param height The height (in pixels) of the image buffer
    414414 *  \param pitch The pitch (in bytes) of an image buffer line.
    415  *  \return This function always returns 0.
     415 *  \return 0 in case of success, -1 if an error occurred.
    416416 */
    417417int cucul_render_canvas(cucul_canvas_t const *cv, cucul_font_t const *f,
    418                         void *buf, unsigned int width,
    419                         unsigned int height, unsigned int pitch)
     418                        void *buf, int width, int height, int pitch)
    420419{
    421420    uint8_t *glyph = NULL;
    422     unsigned int x, y, xmax, ymax;
     421    int x, y, xmax, ymax;
     422
     423    if(width < 0 || height < 0 || pitch < 0)
     424    {
     425        seterrno(EINVAL);
     426        return -1;
     427    }
    423428
    424429    if(f->header.bpp != 8)
     
    440445        {
    441446            uint8_t argb[8];
    442             unsigned int starty = y * f->header.height;
    443             unsigned int startx = x * f->header.width;
     447            int starty = y * f->header.height;
     448            int startx = x * f->header.width;
    444449            uint32_t ch = cv->chars[y * cv->width + x];
    445450            uint32_t attr = cv->attrs[y * cv->width + x];
    446             unsigned int b, i, j;
     451            int b, i, j;
    447452            struct glyph_info *g;
    448453
Note: See TracChangeset for help on using the changeset viewer.