SomBeginPersistentIds
Appearance
Description
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
- somCheckId
- somRegisterId
- somIdFromString
- somStringFromId
- somCompareIds
- somTotalRegIds
- somUniqueKey
- somSetExpectedIds
- somEndPersistentIds