source: libcaca/trunk/cucul/buffer.c @ 870

Last change on this file since 870 was 870, checked in by Sam Hocevar, 15 years ago
  • Check for <errno.h>.
  • Started changing function prototypes so that they return an integer instead of void, just in case they might fail.
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1/*
2 *  libcucul      Canvas for ultrafast compositing of Unicode letters
3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: buffer.c 870 2006-04-25 09:59:58Z sam $
7 *
8 *  This library is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14/*
15 *  This file contains buffer handling functions.
16 */
17
18#include "config.h"
19#include "common.h"
20
21#if !defined(__KERNEL__)
22#   include <stdio.h>
23#   include <stdlib.h>
24#   include <string.h>
25#endif
26
27#include "cucul.h"
28#include "cucul_internals.h"
29
30/** \brief Get the buffer size.
31 *
32 *  This function returns the length (in bytes) of the memory area stored
33 *  in the given \e libcucul buffer.
34 *
35 *  This function never fails.
36 *
37 *  \param buf A \e libcucul buffer
38 *  \return The buffer data length.
39 */
40unsigned long int cucul_get_buffer_size(cucul_buffer_t *buf)
41{
42    return buf->size;
43}
44
45/** \brief Get the buffer data.
46 *
47 *  This function returns a pointer to the memory area stored in the given
48 *  \e libcucul buffer.
49 *
50 *  This function never fails.
51 *
52 *  \param buf A \e libcucul buffer
53 *  \return A pointer to the buffer memory area.
54 */
55void * cucul_get_buffer_data(cucul_buffer_t *buf)
56{
57    return buf->data;
58}
59
60/** \brief Free a buffer.
61 *
62 *  This function frees the structures associated with the given
63 *  \e libcucul buffer.
64 *
65 *  This function never fails.
66 *
67 *  \param buf A \e libcucul buffer
68 *  \return This function always returns 0.
69 */
70int cucul_free_buffer(cucul_buffer_t *buf)
71{
72    free(buf->data);
73    free(buf);
74
75    return 0;
76}
77
Note: See TracBrowser for help on using the repository browser.