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