Changeset 1468


Ignore:
Timestamp:
08/05/10 17:45:28 (21 months ago)
Author:
Freddie Akeroyd
Message:

Add malloc() and free() methods Refs #227

Location:
trunk/bindings/cpp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bindings/cpp/NeXusFile.cpp

    r1444 r1468  
    118118static int check_char_too_big[1 - sizeof(char) + ARRAY_OFFSET]; // error if char > 1 byte 
    119119 
    120 static void inner_malloc(void* & data, std::vector<int>& dims, NXnumtype type) { 
     120static void inner_malloc(void* & data, const std::vector<int>& dims, NXnumtype type) { 
    121121  int rank = dims.size(); 
    122122  int c_dims[NX_MAXRANK]; 
     
    963963  } 
    964964} 
     965 
     966template<typename NumT> 
     967void File::malloc(NumT*& data, const Info& info) 
     968{ 
     969    if (getType<NumT>() != info.type) 
     970    { 
     971        throw Exception("Type mismatch in malloc()"); 
     972    } 
     973    inner_malloc((void*&)data, info.dims, info.type); 
     974} 
     975 
     976template<typename NumT> 
     977void File::free(NumT*& data) 
     978{ 
     979    inner_free((void*&)data); 
     980} 
     981 
    965982} 
    966983 
     
    11931210template  
    11941211NXDLL_EXPORT void File::getAttr(const std::string& name, int& value); 
     1212 
     1213template 
     1214NXDLL_EXPORT void File::malloc(int*& data, const Info& info); 
     1215template 
     1216NXDLL_EXPORT void File::malloc(float*& data, const Info& info); 
     1217template 
     1218NXDLL_EXPORT void File::malloc(double*& data, const Info& info); 
     1219 
     1220template 
     1221NXDLL_EXPORT void File::free(int*& data); 
     1222template 
     1223NXDLL_EXPORT void File::free(float*& data); 
     1224template 
     1225NXDLL_EXPORT void File::free(double*& data); 
  • trunk/bindings/cpp/NeXusFile.hpp

    r1466 r1468  
    162162    void flush(); 
    163163 
     164    template<typename NumT> 
     165    void malloc(NumT*& data, const Info& info); 
     166 
     167    template<typename NumT> 
     168    void free(NumT*& data); 
     169 
    164170    /** 
    165171     * Create a new group. 
Note: See TracChangeset for help on using the changeset viewer.