Line-by-line Anatomy of DB.c
(Cont.)
StrPrintF( buf, "%ld record(s) still locked.", locks );
This function Int16 StrPrintF( Char *s, const Char *formatStr, ... ) implements a subset of the ANSI C sprintf
call, which writes formatted output to a string.
s
:
Pointer to a string into which the results are written
formatStr
:
Pointer to the format specification string
...
:
Zero or more arguments to be formatted as specified by formatStr
DmCloseDatabase( db );
This function Err DmCloseDatabase( DmOpenRef dbP ) closes a database.
dbP
:
Database access pointer
This routine does not unlock any records that were left locked.
Records and resources should not be left locked.
If a record/resource is left locked, you should not use its reference because the record can disappear during a HotSync operation or if the database is deleted by the user.
To prevent the DB from being deleted, you can use DmDatabaseProtect( ) before closing.
DmNewRecord( db, &index, sizeof( DBRecordType ) )
This function MemHandle DmNewRecord( DmOpenRef dbP, UInt16 *atP, UInt32 size ) returns a handle to a new record in the database and marks the record busy.
dbP
:
DmOpenRef
to open database
atP
:
Pointer to index where new record should be placed.
Specify the value dmMaxRecordIndex
to add the record to the end of the database.
size
:
Size of new record
Both the busy
and dirty
bits are set for the new record and a unique ID is automatically created.
DmReleaseRecord( ) should be called as soon as the caller finishes viewing or editing the record.