DSMCC  17.9.0
 All Data Structures Files Functions Typedefs
dsmObject.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  * Copyright © 2002 Koninklijke Philips Electronics N.V
5  *
6  * This file is part of a DTVKit Software Component
7  * You are permitted to copy, modify or distribute this file subject to the terms
8  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
9  *
10  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
11  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * If you or your organisation is not a member of DTVKit then you have access
15  * to this source code outside of the terms of the licence agreement
16  * and you are expected to delete this and any associated files immediately.
17  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
18  *******************************************************************************/
25 /*---includes for this file--------------------------------------------------*/
26 #include "clDsmSystem.h"
27 #include "dsmObject.h"
28 
29 #include "linkList.h"
30 #include "cacheMgr.h"
31 
32 
33 /*------------------------------- Local Macros -------------------------------*/
34 
35 
36 /*------------------------------ Exported Data -----------------------------*/
37 
38 
39 /*--------------------------------Local Types --------------------------------*/
40 
41 
42 /*------------------------------- Local Statics ------------------------------*/
43 
44 
45 /*------------------- Local prototypes/forward declarations ------------------*/
46 
47 
48 /*---------------------------- Exported Functions ----------------------------*/
49 
50 /* /////////////////////////////////////////////////////////////////////////////
51 // objectCreate
52 // Creates an instance of the Object struct, and initialises it.
53 // NB. objectKey not supplied since it may not be known when object
54 // is first created.
56 E_DscError objectCreate( P_DsmCoreInst idp, P_DsmObject *ppObject )
57 {
58  P_DsmObject pObject = NULL;
59  E_DscError err;
60 
61  dsmAssert((idp != NULL));
62  dsmAssert((ppObject != NULL));
63 
64  pObject = (P_DsmObject)DSC_CmMemGet( idp, sizeof(S_DsmObject) );
65  if (!pObject)
66  {
67  err = CLDSM_ERR_MEM_HEAP_FULL;
68  }
69  else
70  {
71  err = CLDSM_OK;
72  memset( pObject, 0, sizeof(S_DsmObject));
73 
74  llLinkInit( pObject->llData, NUM_LISTS_OBJECT );
75 
76  pObject->magic = DSM_OBJECT_MAGIC;
77  pObject->myDsmInst = idp;
78  pObject->cachingRules = CACHE_RULES_DEFAULT;
79  }
80  *ppObject = pObject;
81 
82  DEBUG_CHK( err == CLDSM_OK, dsmDP1(("ERROR: objectCreate: %u\n", err)));
83  return err;
84 }
85 
86 /* /////////////////////////////////////////////////////////////////////////////
87 // objectDestroy
88 // Destroys an instance of the Object struct, and all associated data.
90 void objectDestroy( P_DsmCoreInst idp, P_DsmObject pObject )
91 {
92  dsmAssert((idp != NULL));
93  dsmAssert((pObject != NULL));
94 
95  dsmAssert((pObject->llData[CURR_OBJECT_LIST].pLLCtrl == NULL));
96  dsmAssert((pObject->llData[MODULE_OBJECT_LIST].pLLCtrl == NULL));
97  dsmAssert((pObject->magic == DSM_OBJECT_MAGIC));
98 
99  /* -- Should not have loadRequest assigned */
100  dsmAssert((pObject->r.pLoadRequest == NULL));
101 
102  /* -- Should not have hModule assigned */
103  dsmAssert((pObject->pModule == NULL));
104 
105  /* -- TODO: Should we do this here or just have debug assert ? */
106  if (pObject->objectDataSeq)
107  {
108  dsmDP3(("INFO: objectDestroy - object still open (forced closed)\n"));
109  memSeqClose( pObject->objectDataSeq );
110  idp->dsmObjectsOpen--;
111  }
112 
113  /* -- NULL dsmObject magic and myDsmInst.
114  -- NB. Should allow error to be detected if destroyed object is
115  -- erroneously re-used (not guaranteed since may depend on MemMgr
116  -- implementation) */
117  pObject->magic = 0;
118  pObject->myDsmInst = NULL;
119 
120  /* -- Use original handle here so it gets Nulled */
121  DSC_CmMemRelease( idp, pObject );
122 
123  dsmDP3(("exit objectDestroy\n"));
124 }
125 
126 /*----------------------------------------------------------------------------*/
General include file for clDsm library internal definitions.
Header to the cacheMgr module.
Header to dsmObject module - functions for managing DSM object heap.