root/plugin/alloc/mallocwrappers.cpp

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. dmtcp_alloc_enabled
  2. calloc
  3. malloc
  4. memalign
  5. posix_memalign
  6. valloc
  7. free
  8. realloc

   1 /****************************************************************************
   2  *   Copyright (C) 2006-2013 by Jason Ansel, Kapil Arya, and Gene Cooperman *
   3  *   jansel@csail.mit.edu, kapil@ccs.neu.edu, gene@ccs.neu.edu              *
   4  *                                                                          *
   5  *   This file is part of the dmtcp/src module of DMTCP (DMTCP:dmtcp/src).  *
   6  *                                                                          *
   7  *  DMTCP:dmtcp/src is free software: you can redistribute it and/or        *
   8  *  modify it under the terms of the GNU Lesser General Public License as   *
   9  *  published by the Free Software Foundation, either version 3 of the      *
  10  *  License, or (at your option) any later version.                         *
  11  *                                                                          *
  12  *  DMTCP:dmtcp/src is distributed in the hope that it will be useful,      *
  13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of          *
  14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
  15  *  GNU Lesser General Public License for more details.                     *
  16  *                                                                          *
  17  *  You should have received a copy of the GNU Lesser General Public        *
  18  *  License along with DMTCP:dmtcp/src.  If not, see                        *
  19  *  <http://www.gnu.org/licenses/>.                                         *
  20  ****************************************************************************/
  21 
  22 #include <stdlib.h>
  23 #include <unistd.h>
  24 #include "dmtcp.h"
  25 #include "alloc.h"
  26 
  27 EXTERNC int dmtcp_alloc_enabled() { return 1; }
  28 
  29 extern "C" void *calloc(size_t nmemb, size_t size)
  30 {
  31   DMTCP_PLUGIN_DISABLE_CKPT();
  32   void *retval = _real_calloc ( nmemb, size );
  33   DMTCP_PLUGIN_ENABLE_CKPT();
  34   return retval;
  35 }
  36 
  37 extern "C" void *malloc(size_t size)
  38 {
  39   DMTCP_PLUGIN_DISABLE_CKPT();
  40   void *retval = _real_malloc ( size );
  41   DMTCP_PLUGIN_ENABLE_CKPT();
  42   return retval;
  43 }
  44 
  45 extern "C" void *memalign(size_t boundary, size_t size)
  46 {
  47   DMTCP_PLUGIN_DISABLE_CKPT();
  48   void *retval = _real_memalign(boundary, size);
  49   DMTCP_PLUGIN_ENABLE_CKPT();
  50   return retval;
  51 }
  52 
  53 extern "C" int posix_memalign(void **memptr, size_t alignment, size_t size)
  54 {
  55   DMTCP_PLUGIN_DISABLE_CKPT();
  56   int retval = _real_posix_memalign(memptr, alignment, size);
  57   DMTCP_PLUGIN_ENABLE_CKPT();
  58   return retval;
  59 }
  60 
  61 extern "C" void *valloc(size_t size)
  62 {
  63   DMTCP_PLUGIN_DISABLE_CKPT();
  64   void *retval = _real_valloc(size);
  65   DMTCP_PLUGIN_ENABLE_CKPT();
  66   return retval;
  67 }
  68 
  69 extern "C" void free(void *ptr)
  70 {
  71   DMTCP_PLUGIN_DISABLE_CKPT();
  72   _real_free ( ptr );
  73   DMTCP_PLUGIN_ENABLE_CKPT();
  74 }
  75 
  76 extern "C" void *realloc(void *ptr, size_t size)
  77 {
  78   DMTCP_PLUGIN_DISABLE_CKPT();
  79   void *retval = _real_realloc ( ptr, size );
  80   DMTCP_PLUGIN_ENABLE_CKPT();
  81   return retval;
  82 }
  83 

/* [<][>][^][v][top][bottom][index][help] */