LCOV - code coverage report
Current view: top level - store/source - object.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 18 20 90.0 %
Date: 2014-04-11 Functions: 6 8 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "object.hxx"
      21             : 
      22             : #include "sal/types.h"
      23             : #include "rtl/alloc.h"
      24             : #include "rtl/ref.hxx"
      25             : #include "osl/diagnose.h"
      26             : #include "osl/interlck.h"
      27             : 
      28             : namespace store
      29             : {
      30             : 
      31             : /*========================================================================
      32             :  *
      33             :  * OStoreObject implementation.
      34             :  *
      35             :  *======================================================================*/
      36             : const sal_uInt32 OStoreObject::m_nTypeId = sal_uInt32(0x58190322);
      37             : 
      38             : /*
      39             :  * OStoreObject.
      40             :  */
      41        1931 : OStoreObject::OStoreObject (void)
      42        1931 :     : m_nRefCount (0)
      43             : {
      44        1931 : }
      45             : 
      46             : /*
      47             :  * ~OStoreObject.
      48             :  */
      49        1931 : OStoreObject::~OStoreObject (void)
      50             : {
      51             :     OSL_ASSERT(m_nRefCount == 0);
      52        1931 : }
      53             : 
      54             : /*
      55             :  * operator new.
      56             :  */
      57        1931 : void* OStoreObject::operator new (size_t n)
      58             : {
      59        1931 :     return rtl_allocateMemory (n);
      60             : }
      61             : 
      62             : /*
      63             :  * operator delete.
      64             :  */
      65        1931 : void OStoreObject::operator delete (void *p)
      66             : {
      67        1931 :     rtl_freeMemory (p);
      68        1931 : }
      69             : 
      70             : /*
      71             :  * isKindOf.
      72             :  */
      73           0 : bool OStoreObject::isKindOf (sal_uInt32 nTypeId)
      74             : {
      75           0 :     return (nTypeId == m_nTypeId);
      76             : }
      77             : 
      78             : /*
      79             :  * acquire.
      80             :  */
      81       37279 : oslInterlockedCount SAL_CALL OStoreObject::acquire (void)
      82             : {
      83       37279 :     oslInterlockedCount result = osl_atomic_increment (&m_nRefCount);
      84       37279 :     return (result);
      85             : }
      86             : 
      87             : /*
      88             :  * release.
      89             :  */
      90       37279 : oslInterlockedCount SAL_CALL OStoreObject::release (void)
      91             : {
      92       37279 :     oslInterlockedCount result = osl_atomic_decrement (&m_nRefCount);
      93       37279 :     if (result == 0)
      94             :     {
      95             :         // Last reference released.
      96        1931 :         delete this;
      97             :     }
      98       37279 :     return (result);
      99             : }
     100             : 
     101             : } // namespace store
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10