Esempio n. 1
0
  ft_object_create( FT_Object  *pobject,
                    FT_Class    clazz,
                    FT_Pointer  init_data )
  {
    FT_Memory  memory;
    FT_Error   error;
    FT_Object  obj;

    FT_ASSERT_IS_CLASS(clazz);

    memory = FT_CLASS__MEMORY(clazz);
    if ( !FT_ALLOC( obj, clazz->obj_size ) )
    {
      obj->clazz     = clazz;
      obj->ref_count = 1;

      if ( clazz->obj_init )
      {
        error = clazz->obj_init( obj, init_data );
        if ( error )
        {
          /* IMPORTANT: call the destructor when an error  */
          /*            was detected in the constructor !! */
          if ( clazz->obj_done )
            clazz->obj_done( obj );

          FT_FREE( obj );
        }
      }
    }
    *pobject = obj;
    return error;
  }
Esempio n. 2
0
  ft_object_new( FT_Class    clazz,
                 FT_Pointer  init_data )
  {
    FT_Memory  memory;
    FT_Object  obj;


    FT_ASSERT_IS_CLASS(clazz);

    memory         = FT_CLASS__MEMORY(clazz);
    obj            = ft_mem_alloc( clazz->obj_size, memory );
    obj->clazz     = clazz;
    obj->ref_count = 1;

    if ( clazz->obj_init )
    {
      FT_CleanupStack  stack = FT_MEMORY__CLEANUP(memory);


      ft_cleanup_push( stack, obj, (FT_CleanupFunc) ft_object_cleanup, NULL );

      clazz->obj_init( obj, init_data );

      ft_cleanup_pop( stack, obj, 0 );
    }
    return obj;
  }
Esempio n. 3
0
  ft_object_create( FT_Object  *pobject,
                    FT_Class    clazz,
                    FT_Pointer  init_data )
  {
    FT_Memory  memory;
    FT_Object  obj;

    FT_ASSERT_IS_CLASS(clazz);

    memory         = FT_CLASS__MEMORY(memory);
    obj            = ft_mem_alloc( clazz->obj_size, memory );
    obj->clazz     = clazz;
    obj->ref_count = 1;
    *pobject       = obj;

    if ( clazz->obj_init )
      clazz->obj_init( obj, init_data );
  }