/xbmc/visualizations/XBMCProjectM/libprojectM/wipemalloc.cpp

http://github.com/xbmc/xbmc · C++ · 44 lines · 15 code · 3 blank · 26 comment · 5 complexity · 03548e737a427dea76242c8a11e303fa MD5 · raw file

  1. /**
  2. * projectM -- Milkdrop-esque visualisation SDK
  3. * Copyright (C)2003-2004 projectM Team
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. * See 'LICENSE.txt' included within this release
  19. *
  20. */
  21. /**
  22. * $Id: wipemalloc.c,v 1.1.1.1 2005/12/23 18:05:05 psperl Exp $
  23. *
  24. * Clean memory allocator
  25. */
  26. #include "wipemalloc.h"
  27. void *wipemalloc( size_t count ) {
  28. void *mem = malloc( count );
  29. if ( mem != NULL ) {
  30. memset( mem, 0, count );
  31. } else {
  32. printf( "wipemalloc() failed to allocate %d bytes\n", (int)count );
  33. }
  34. return mem;
  35. }
  36. /** Safe memory deallocator */
  37. void wipefree( void *ptr ) {
  38. if ( ptr != NULL ) {
  39. free( ptr );
  40. }
  41. }