You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

78 rivejä
1.7 KiB

  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$
  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. * This file contains buffer handling functions.
  15. */
  16. #include "config.h"
  17. #include "common.h"
  18. #if !defined(__KERNEL__)
  19. # include <stdio.h>
  20. # include <stdlib.h>
  21. # include <string.h>
  22. #endif
  23. #include "cucul.h"
  24. #include "cucul_internals.h"
  25. /** \brief Get the buffer size.
  26. *
  27. * This function returns the length (in bytes) of the memory area stored
  28. * in the given \e libcucul buffer.
  29. *
  30. * This function never fails.
  31. *
  32. * \param buf A \e libcucul buffer
  33. * \return The buffer data length.
  34. */
  35. unsigned long int cucul_get_buffer_size(cucul_buffer_t *buf)
  36. {
  37. return buf->size;
  38. }
  39. /** \brief Get the buffer data.
  40. *
  41. * This function returns a pointer to the memory area stored in the given
  42. * \e libcucul buffer.
  43. *
  44. * This function never fails.
  45. *
  46. * \param buf A \e libcucul buffer
  47. * \return A pointer to the buffer memory area.
  48. */
  49. void * cucul_get_buffer_data(cucul_buffer_t *buf)
  50. {
  51. return buf->data;
  52. }
  53. /** \brief Free a buffer.
  54. *
  55. * This function frees the structures associated with the given
  56. * \e libcucul buffer.
  57. *
  58. * This function never fails.
  59. *
  60. * \param buf A \e libcucul buffer
  61. * \return This function always returns 0.
  62. */
  63. int cucul_free_buffer(cucul_buffer_t *buf)
  64. {
  65. free(buf->data);
  66. free(buf);
  67. return 0;
  68. }