TuttleOFX  1
ofxMemory.h
Go to the documentation of this file.
00001 #ifndef _ofxMemory_h_
00002 #define _ofxMemory_h_
00003 
00004 /*
00005  * Software License :
00006  *
00007  * Copyright (c) 2003-2009, The Open Effects Association Ltd. All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions are met:
00011  *
00012  * Redistributions of source code must retain the above copyright notice,
00013  *    this list of conditions and the following disclaimer.
00014  * Redistributions in binary form must reproduce the above copyright notice,
00015  *    this list of conditions and the following disclaimer in the documentation
00016  *    and/or other materials provided with the distribution.
00017  * Neither the name The Open Effects Association Ltd, nor the names of its
00018  *    contributors may be used to endorse or promote products derived from this
00019  *    software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00022  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00025  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00026  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00028  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031  */
00032 
00033 #include "ofxCore.h"
00034 
00035 #include <string.h>
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 #define kOfxMemorySuite "OfxMemorySuite"
00042 
00043 /** @brief The OFX suite that implements general purpose memory management.
00044  *
00045  * Use this suite for ordinary memory management functions, where you would normally use malloc/free or new/delete on ordinary objects.
00046  *
00047  * For images, you should use the memory allocation functions in the image effect suite, as many hosts have specific image memory pools.
00048  *
00049  * \note C++ plugin developers will need to redefine new and delete as skins ontop of this suite.
00050  */
00051 typedef struct OfxMemorySuiteV1
00052 {
00053         /** @brief Allocate memory.
00054          *
00055          * \arg handle  - effect instance to assosciate with this memory allocation, or NULL.
00056          * \arg nBytes        - the number of bytes to allocate
00057          * \arg allocatedData - a pointer to the return value. Allocated memory will be alligned for any use.
00058          *
00059          * This function has the host allocate memory using it's own memory resources
00060          * and returns that to the plugin.
00061          *
00062          * @returns
00063          * - ::kOfxStatOK the memory was sucessfully allocated
00064          * - ::kOfxStatErrMemory the request could not be met and no memory was allocated
00065          *
00066          */
00067         OfxStatus ( *memoryAlloc )( void*  handle,
00068                                     size_t nBytes,
00069                                     void** allocatedData );
00070 
00071         /** @brief Frees memory.
00072          *
00073          * \arg allocatedData - pointer to memory previously returned by OfxMemorySuiteV1::memoryAlloc
00074          *
00075          * This function frees any memory that was previously allocated via OfxMemorySuiteV1::memoryAlloc.
00076          *
00077          * @returns
00078          * - ::kOfxStatOK the memory was sucessfully freed
00079          * - ::kOfxStatErrBadHandle \e allocatedData was not a valid pointer returned by OfxMemorySuiteV1::memoryAlloc
00080          *
00081          */
00082         OfxStatus ( *memoryFree )( void* allocatedData );
00083 } OfxMemorySuiteV1;
00084 
00085 
00086 /** @file ofxMemory.h
00087  *  This file contains the API for general purpose memory allocation from a host.
00088  */
00089 
00090 
00091 
00092 #ifdef __cplusplus
00093 }
00094 #endif
00095 
00096 #endif