Ignore:
Timestamp:
Apr 19, 2008, 9:25:52 PM (13 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/canvas.c

    r2304 r2305  
    300300{
    301301    uint32_t attr = cv->curattr;
    302     unsigned int n;
     302    int n;
    303303
    304304    for(n = cv->width * cv->height; n--; )
     
    394394    endj = (y + src->height >= dst->height) ? dst->height - y : src->height;
    395395
    396     if((unsigned int)starti > src->width || (unsigned int)startj > src->height
     396    if(starti > src->width || startj > src->height
    397397        || starti >= endi || startj >= endj)
    398398        return 0;
     
    400400    for(j = startj; j < endj; j++)
    401401    {
    402         unsigned int dstix = (j + y) * dst->width + starti + x;
    403         unsigned int srcix = j * src->width + starti;
     402        int dstix = (j + y) * dst->width + starti + x;
     403        int srcix = j * src->width + starti;
    404404        int stride = endi - starti;
    405405
     
    408408            dst->chars[dstix - 1] = ' ';
    409409
    410         if((unsigned int)(endi + x) < dst->width
     410        if(endi + x < dst->width
    411411                && dst->chars[dstix + stride] == CUCUL_MAGIC_FULLWIDTH)
    412412            dst->chars[dstix + stride] = ' ';
     
    433433            dst->chars[dstix] = ' ';
    434434
    435         if((unsigned int)endi < src->width
    436                 && src->chars[endi] == CUCUL_MAGIC_FULLWIDTH)
     435        if(endi < src->width && src->chars[endi] == CUCUL_MAGIC_FULLWIDTH)
    437436            dst->chars[dstix + stride - 1] = ' ';
    438437    }
     
    448447 *
    449448 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     449 *  - \c EINVAL Specified width or height is invalid.
    450450 *  - \c EBUSY The canvas is in use by a display driver and cannot be resized.
    451451 *  - \c ENOMEM Not enough memory for the requested canvas size. If this
     
    459459 *  \return 0 in case of success, -1 if an error occurred.
    460460 */
    461 int cucul_set_canvas_boundaries(cucul_canvas_t *cv, int x, int y,
    462                                 unsigned int w, unsigned int h)
     461int cucul_set_canvas_boundaries(cucul_canvas_t *cv, int x, int y, int w, int h)
    463462{
    464463    cucul_canvas_t *new;
    465     unsigned int f, saved_f, framecount;
     464    int f, saved_f, framecount;
    466465
    467466    if(cv->refcount)
    468467    {
    469468        seterrno(EBUSY);
     469        return -1;
     470    }
     471
     472    if(w < 0 || h < 0)
     473    {
     474        seterrno(EINVAL);
    470475        return -1;
    471476    }
Note: See TracChangeset for help on using the changeset viewer.