PageRenderTime 20ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/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
27#include "wipemalloc.h"
28
29 void *wipemalloc( size_t count ) {
30    void *mem = malloc( count );
31    if ( mem != NULL ) {
32        memset( mem, 0, count );
33      } else {
34        printf( "wipemalloc() failed to allocate %d bytes\n", (int)count );
35      }
36    return mem;
37  }
38
39/** Safe memory deallocator */
40 void wipefree( void *ptr ) {
41    if ( ptr != NULL ) {
42        free( ptr );
43      }
44  }