graphicscomposition/openwfcompositionengine/common/src/owfobject.c
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 /* Copyright (c) 2009 The Khronos Group Inc.
       
     2  *
       
     3  * Permission is hereby granted, free of charge, to any person obtaining a
       
     4  * copy of this software and/or associated documentation files (the
       
     5  * "Materials"), to deal in the Materials without restriction, including
       
     6  * without limitation the rights to use, copy, modify, merge, publish,
       
     7  * distribute, sublicense, and/or sell copies of the Materials, and to
       
     8  * permit persons to whom the Materials are furnished to do so, subject to
       
     9  * the following conditions:
       
    10  *
       
    11  * The above copyright notice and this permission notice shall be included
       
    12  * in all copies or substantial portions of the Materials.
       
    13  *
       
    14  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
       
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
       
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
       
    18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
       
    19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
       
    20  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
       
    21  */
       
    22 
       
    23 #include "owfobject.h"
       
    24 #include "owftypes.h"
       
    25 #include "owfmemory.h"
       
    26 
       
    27 
       
    28 #ifdef __cplusplus
       
    29 extern "C"
       
    30 {
       
    31 #endif
       
    32 
       
    33 
       
    34 
       
    35 OWF_API_CALL void*
       
    36 OWF_Object_Construct(size_t size,
       
    37                      const char* type,
       
    38                      CONSTRUCTOR ctor,
       
    39                      DESTRUCTOR dtor)
       
    40 {
       
    41     OWF_OBJECT* obu = (OWF_OBJECT*) xalloc(sizeof(OWF_OBJECT) + size, 1);
       
    42 
       
    43     if (obu)
       
    44     {
       
    45         obu->type = type;
       
    46         obu->destructor = dtor;
       
    47         obu->referenceCount = 1;
       
    48         if (ctor)
       
    49         {
       
    50             ctor(&obu->payload);
       
    51         }
       
    52         DPRINT(("CREATE: created %s object (%p)\n", type, &obu->payload));
       
    53         return &obu->payload;
       
    54     }
       
    55 
       
    56     return NULL;
       
    57 }
       
    58 
       
    59 
       
    60 
       
    61 #ifdef __cplusplus
       
    62 }
       
    63 #endif