home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 February / PCO_0299.ISO / filesbbs / linux / mikmod-3.000 / mikmod-3 / mikmod-3.1.2 / mmio / mmalloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-07  |  1.6 KB  |  56 lines

  1. /*    MikMod sound library
  2.     (c) 1998 Miodrag Vallat and others - see file AUTHORS for complete list
  3.  
  4.     This library is free software; you can redistribute it and/or modify
  5.     it under the terms of the GNU Library General Public License as
  6.     published by the Free Software Foundation; either version 2 of
  7.     the License, or (at your option) any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public
  15.     License along with this library; if not, write to the Free Software
  16.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19. /*==============================================================================
  20.  
  21.   $Id: mmalloc.c,v 1.12 1998/12/07 06:00:38 miod Exp $
  22.  
  23.   Dynamic memory routines
  24.  
  25. ==============================================================================*/
  26.  
  27. #ifdef HAVE_CONFIG_H
  28. #include "config.h"
  29. #endif
  30.  
  31. #include <mikmod_internals.h>
  32.  
  33. /* Same as malloc, but sets error variable _mm_error when fails */
  34. void* _mm_malloc(size_t size)
  35. {
  36.     void *d;
  37.  
  38.     if(!(d=calloc(1,size))) {
  39.         _mm_errno = MMERR_OUT_OF_MEMORY;
  40.         if(_mm_errorhandler) _mm_errorhandler();
  41.     }
  42.     return d;
  43. }
  44.  
  45. /* Same as calloc, but sets error variable _mm_error when fails */
  46. void* _mm_calloc(size_t nitems,size_t size)
  47. {
  48.     void *d;
  49.    
  50.     if(!(d=calloc(nitems,size))) {
  51.         _mm_errno = MMERR_OUT_OF_MEMORY;
  52.         if(_mm_errorhandler) _mm_errorhandler();
  53.     }
  54.     return d;
  55. }
  56.