Ignore:
Timestamp:
05/01/12 17:28:47 (13 years ago)
Author:
cborstad
Message:

merged trunk-jpl into branch through revision 12167

Location:
issm/branches/trunk-jpl-damage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/branches/trunk-jpl-damage

  • issm/branches/trunk-jpl-damage/src/c/shared/Alloc/alloc.cpp

    r12004 r12168  
    1919#endif
    2020
    21 #if defined(_SERIAL_) && defined(_HAVE_MATLAB_)
    22 #include "mex.h"
    23 #endif
    24 
    2521#include <stdio.h>
    2622#include <stdlib.h>
     
    3733        if(!size)_error_(" attempting to 0 size allocation!");
    3834
    39         #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
    40         /* Use the matlab api to do the allocation: */
    41         memptr=mxMalloc(size);
    42         #else
    4335        /* Use the c library to do the allocation: */
    4436        memptr=malloc(size);
    45         #endif
    4637        if(!memptr) _error_("memory allocation failed!");
    4738
     
    5546        if(!size)_error_("attempting to 0 size allocation!");
    5647
    57         #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
    58         /* Use the matlab api to do the allocation: */
    59         memptr=mxCalloc(n,size);
    60         #else
    6148        /* Use the c library to do the allocation: */
    6249        memptr=calloc(n,size);
    63         #endif
    6450        if(!memptr) _error_("memory allocation failed!");
    6551
     
    7056
    7157        if (pv && *pv){
    72                 #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
    73                         mxFree(*pv);
    74                 #else
    75                         free(*pv);
    76                 #endif
     58                free(*pv);
    7759
    7860                *pv=NULL;
     
    8365       
    8466        if (pv && *pv){
    85                 #ifdef _PARALLEL_
    8667                /*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we
    8768                 * don't actually free memory in Matlab, we let the memory manager do that. We only
    8869                 * free in parallel: */
    8970                delete *pv;
    90                 #else
    91                 /*Actually, still get rid of internal Petsc matrix. Quick fix until Matlab handles C++
    92                  * correctly: */
    93                 #ifdef _HAVE_PETSC_
    94                         MatFree(&(*pv)->matrix);
    95                 #endif
    96                 #endif
    9771                *pv=NULL;
    9872        }
     
    10276
    10377        if (pv && *pv){
    104                 #ifdef _PARALLEL_
    10578                /*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we
    10679                 * don't actually free memory in Matlab, we let the memory manager do that. We only
    10780                 * free in parallel: */
    10881                delete *pv;
    109                 #else
    110                 /*Actually, still get rid of internal Petsc vector. Quick fix until Matlab handles C++
    111                  * correctly: */
    112                 #ifdef _HAVE_PETSC_
    113                         VecFree(&(*pv)->vector);
    114                 #endif
    115                 #endif
    11682                *pv=NULL;
    11783        }
     
    12490       
    12591        if(!size)_error_("attempting to realloc to zero");
    126 
    127         #if defined(_HAVE_MATLAB_) && defined(_SERIAL_)
    128         value = (void*)mxRealloc(pv,size);
    129         #else
    13092        value = (void*)realloc(pv,size);
    131         #endif
    13293
    13394        if (value == NULL) {
Note: See TracChangeset for help on using the changeset viewer.