Ignore:
Timestamp:
Apr 27, 2006, 4:15:23 PM (15 years ago)
Author:
Sam Hocevar
Message:
  • Completed return value and errno handling in libcucul API.
File:
1 edited

Legend:

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

    r896 r920  
    2121
    2222#if !defined(__KERNEL__)
     23#   if defined(HAVE_ERRNO_H)
     24#       include <errno.h>
     25#   endif
    2326#   include <stdlib.h>
    2427#   include <stdio.h>
     
    6467 *  \li \c "tga": export a TGA image.
    6568 *
     69 *  If an error occurs, NULL is returned and \b errno is set accordingly:
     70 *  - \c EINVAL Invalid format requested.
     71 *  - \c ENOMEM Not enough memory to allocate output buffer.
     72 *
    6673 *  \param cv A libcucul canvas
    6774 *  \param format A string describing the requested output format.
     75 *  \return A libcucul buffer, or NULL in case of error.
    6876 */
    6977cucul_buffer_t * cucul_export_canvas(cucul_canvas_t *cv, char const *format)
     
    7280
    7381    ex = malloc(sizeof(cucul_buffer_t));
     82    if(!ex)
     83    {
     84#if defined(HAVE_ERRNO_H)
     85        errno = ENOMEM;
     86#endif
     87        return NULL;
     88    }
     89
    7490    ex->size = 0;
    7591    ex->data = NULL;
     
    96112    {
    97113        free(ex);
     114#if defined(HAVE_ERRNO_H)
     115        errno = EINVAL;
     116#endif
    98117        return NULL;
    99118    }
     
    108127 *  the export format, to be used with cucul_export_canvas(), and a string
    109128 *  containing the natural language description for that export format.
     129 *
     130 *  This function never fails.
    110131 *
    111132 *  \return An array of strings.
Note: See TracChangeset for help on using the changeset viewer.