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/frame.c

    r2299 r2305  
    3737 *  \return The frame count
    3838 */
    39 unsigned int cucul_get_frame_count(cucul_canvas_t const *cv)
     39int cucul_get_frame_count(cucul_canvas_t const *cv)
    4040{
    4141    return cv->framecount;
     
    5757 *  \return 0 in case of success, -1 if an error occurred.
    5858 */
    59 int cucul_set_frame(cucul_canvas_t *cv, unsigned int id)
    60 {
    61     if(id >= cv->framecount)
     59int cucul_set_frame(cucul_canvas_t *cv, int id)
     60{
     61    if(id < 0 || id >= cv->framecount)
    6262    {
    6363        seterrno(EINVAL);
     
    125125 *  values range from 0 to the current canvas frame count. If the frame
    126126 *  index is greater than or equals the current canvas frame count, the new
    127  *  frame is appended at the end of the canvas.
     127 *  frame is appended at the end of the canvas. If the frame index is less
     128 *  than zero, the new frame is inserted at index 0.
    128129 *
    129130 *  The active frame does not change, but its index may be renumbered due
     
    137138 *  \return 0 in case of success, -1 if an error occurred.
    138139 */
    139 int cucul_create_frame(cucul_canvas_t *cv, unsigned int id)
    140 {
    141     unsigned int size = cv->width * cv->height;
    142     unsigned int f;
    143 
    144     if(id > cv->framecount)
     140int cucul_create_frame(cucul_canvas_t *cv, int id)
     141{
     142    int size = cv->width * cv->height;
     143    int f;
     144
     145    if(id < 0)
     146        id = 0;
     147    else if(id > cv->framecount)
    145148        id = cv->framecount;
    146149
     
    195198 *  \return 0 in case of success, -1 if an error occurred.
    196199 */
    197 int cucul_free_frame(cucul_canvas_t *cv, unsigned int id)
    198 {
    199     unsigned int f;
    200 
    201     if(id >= cv->framecount)
     200int cucul_free_frame(cucul_canvas_t *cv, int id)
     201{
     202    int f;
     203
     204    if(id < 0 || id >= cv->framecount)
    202205    {
    203206        seterrno(EINVAL);
Note: See TracChangeset for help on using the changeset viewer.