Jump to content

SomBeginPersistentIds: Difference between revisions

From EDM2
Created page with "==Description== This functions tells SOM to begin a "persistent ID interval." ==Syntax== <PRE> somBeginPersistentIds(); </PRE> ==Parameters== N/A ==Return Code== * rc ==Re..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
{{DISPLAYTITLE:somBeginPersistentIds}}
This functions tells SOM to begin a "persistent ID interval."  
This functions tells SOM to begin a "persistent ID interval."


==Syntax==
==Syntax==
<PRE>
somBeginPersistentIds();
somBeginPersistentIds();
 
</PRE>
==Parameters==
==Parameters==
N/A
N/A
Line 13: Line 12:


==Remarks==
==Remarks==
This function informs the SOM ID manager that strings for any new SOM IDs that are registered will not be freed or modified. This allows the ID manager to use a pointer to the string in the unregistered ID as the master copy of the ID's string, rather than making a copy of the string. This makes ID handling more efficient.  
This function informs the SOM ID manager that strings for any new SOM IDs that are registered will not be freed or modified. This allows the ID manager to use a pointer to the string in the unregistered ID as the master copy of the ID's string, rather than making a copy of the string. This makes ID handling more efficient.


==Example Code==
==Example Code==
<PRE>
<PRE>
#include <som.h>
#include <som.h>
Line 52: Line 50:
</PRE>
</PRE>


==Related==
==Related Functions==
===Functions===
* [[somCheckId]]
* [[somCheckId]]
* [[somRegisterId]]
* [[somRegisterId]]
Line 64: Line 61:
* [[somEndPersistentIds]]
* [[somEndPersistentIds]]


 
[[Category:SOM function]]
[[Category:The OS/2 API Project]]
[[Category:SOM Kernel]]

Latest revision as of 02:21, 6 May 2020

This functions tells SOM to begin a "persistent ID interval."

Syntax

somBeginPersistentIds();

Parameters

N/A

Return Code

  • rc

Remarks

This function informs the SOM ID manager that strings for any new SOM IDs that are registered will not be freed or modified. This allows the ID manager to use a pointer to the string in the unregistered ID as the master copy of the ID's string, rather than making a copy of the string. This makes ID handling more efficient.

Example Code

#include <som.h>
/* This is the way to create somIds efficiently */
static string id1Name = "whoami";
static somId somId_id1 = &id1Name;
/*
   somId_id1 will be registered the first time it is used
   in an operation that takes a somId, or it can be explicitly
   registered using somCheckId.
*/

main()
{
   somId id1, id2;
   string id2Name = "whereami";

   somEnvironmentNew();
   somBeginPersistentIds();
   id1 = somCheckId(somId_id1); /* registers the id as persistent */
   somEndPersistentIds();
   id2 = somIdFromString(id2Name); /* registers the id */

   SOM_Assert(!strcmp("whoami", somStringFromId(id1)), SOM_Fatal);
   SOM_Assert(!strcmp("whereami", somStringFromId(id2)), SOM_Fatal);

   id1Name = "it does matter"; /* because it is persistent */
   id2Name = "it doesn't matter"; /* because it is not persistent */

   SOM_Assert(strcmp("whoami", somStringFromId(id1)), SOM_Fatal);
   /* The id1 string has changed */
   SOM_Assert(!strcmp("whereami", somStringFromId(id2)), SOM_Fatal);
   /* the id2 string has not */
}

Related Functions