本文整理汇总了C++中MemHandleUnlock函数的典型用法代码示例。如果您正苦于以下问题:C++ MemHandleUnlock函数的具体用法?C++ MemHandleUnlock怎么用?C++ MemHandleUnlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MemHandleUnlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MainFormInit
/***********************************************************************
*
* FUNCTION: MainFormInit
*
* DESCRIPTION: This routine initializes the MainForm form.
*
* PARAMETERS: frm - pointer to the MainForm form.
*
* RETURNED: nothing
*
* REVISION HISTORY:
*
*
***********************************************************************/
static void MainFormInit(FormPtr frmP)
{
FieldPtr fld;
char *ptr;
MemHandle mh = MemHandleNew (10);
fld = GetObjectPtr (MainSymbolField);
ptr = MemHandleLock (mh);
strcpy(ptr,"IBM");
FldSetTextHandle (fld, mh);
MemHandleUnlock(mh);
}
示例2: ReturnRecordHandle
static UInt16 ConvertBookmarksForRecord
(
UInt16 recordId,
UInt8* bookmarkPtr,
OldBookmarkData* dataPtr,
UInt16 entries,
Boolean* done
)
{
UInt16 i;
Header* record = NULL;
MemHandle handle = NULL;
Boolean success = true;
for ( i = 0 ; i < entries ; i++ ) {
if ( dataPtr->recordId == recordId ) {
AnnotationEntry e;
if ( handle == NULL ) {
handle = ReturnRecordHandle( recordId );
if ( handle == NULL )
return false;
record = MemHandleLock( handle );
}
MemSet( &e, sizeof( AnnotationEntry ), 0 );
e.flags = ANNOTATION_BOOKMARK | ANNOTATION_HIDDEN;
e.triggerStart = dataPtr->characterPosition;
e.triggerStop = dataPtr->characterPosition;
e.id.uid = dataPtr->recordId;
e.id.paragraphNum = GetParagraphNumber( record, e.triggerStart );
e.id.indexInParagraph = NEW_ANNOTATION;
success = AddAnnotation( &e, bookmarkPtr ) && success;
done[ i ] = true;
}
bookmarkPtr += StrLen( bookmarkPtr ) + 1;
dataPtr++;
}
if ( handle != NULL ) {
MemHandleUnlock( handle );
FreeRecordHandle( &handle );
}
return success;
}
示例3: Assert
// Open preferences database and find a record that contains preferences.
// Return errNone if opened succesfully, otherwise an error:
// psErrNoPrefDatabase - pref database couldn't be found
// devnote: it scans through all records even though we only store preferences
// in one record because I want to be able to use preferences database used
// in earlier versions of Noah Pro/Thes.
Err PrefsStoreReader::ErrOpenPrefsDatabase()
{
if (_db)
{
Assert(_recHandle);
Assert(_recData);
return errNone;
}
// we already tried to open the database but couldn't, so don't try again
if (_fDbNotFound)
return psErrNoPrefDatabase;
LocalID dbId;
Err err = ErrFindDatabaseByNameTypeCreator(_dbName, _dbType, _dbCreator, &dbId);
if (dmErrCantFind==err)
{
err = psErrNoPrefDatabase;
goto ExitAndMarkNotFound;
}
if (err)
goto ExitAndMarkNotFound;
Assert(0!=dbId);
_db = DmOpenDatabase(0, dbId, dmModeReadWrite);
if (!_db)
{
err = DmGetLastErr();
Assert(err);
goto ExitAndMarkNotFound;
}
UInt16 recsCount = DmNumRecords(_db);
for (UInt16 recNo = 0; recNo < recsCount; recNo++)
{
_recHandle = DmQueryRecord(_db, recNo);
_recData = (unsigned char*)MemHandleLock(_recHandle);
if ( (MemHandleSize(_recHandle)>=4) && FValidPrefsStoreRecord(_recData) )
{
// we found the record with prefernces so remember _recData and _recHandle
// those must be freed in destructor
return errNone;
}
MemHandleUnlock(_recHandle);
_recHandle = NULL;
}
DmCloseDatabase(_db);
_db = 0;
err = psErrNoPrefDatabase;
ExitAndMarkNotFound:
_fDbNotFound = true;
return err;
}
示例4: DrawCourses
/*****************************************************************************
* Function: DrawCourses
*
* Description: local function to fill the course list
*****************************************************************************/
static void
DrawCourses(ListType *lst)
{
MemHandle mWebsite, mEmail, old;
Char *buffer;
FieldType *fldWebsite, *fldEmail;
gNumCourses=CountCourses();
gCourseList = (Char **) MemPtrNew(gNumCourses * sizeof(Char *));
gCourseInd = (UInt16 *) MemPtrNew(gNumCourses * sizeof(UInt16));
CourseListGen(gCourseList, NULL, gCourseInd, gNumCourses, 0, CLIST_SEARCH_INDEX);
LstSetListChoices(lst, gCourseList, gNumCourses);
LstSetSelection(lst, -1);
fldWebsite = GetObjectPtr(FIELD_cl_website);
fldEmail = GetObjectPtr(FIELD_cl_email);
mWebsite = MemHandleNew(4);
buffer = MemHandleLock(mWebsite);
MemSet(buffer, 4, 0);
StrCopy(buffer, "-?-");
MemHandleUnlock(mWebsite);
old = FldGetTextHandle(fldWebsite);
FldSetTextHandle(fldWebsite, mWebsite);
if (old != NULL) MemHandleFree(old);
mEmail = MemHandleNew(4);
buffer = MemHandleLock(mEmail);
MemSet(buffer, 4, 0);
StrCopy(buffer, "-?-");
MemHandleUnlock(mEmail);
old = FldGetTextHandle(fldEmail);
FldSetTextHandle(fldEmail, mEmail);
if (old != NULL) MemHandleFree(old);
}
示例5: GetLastDocInfo
/* Return info for last openned document */
DocumentInfo* GetLastDocInfo( void )
{
DocumentInfo* docInfo;
docInfo = NULL;
if ( plkrDocList == NULL ) {
plkrDocList = DmOpenDatabaseByTypeCreator( PlkrDocListType, ViewerAppID,
dmModeReadWrite );
}
if ( plkrDocList != NULL ) {
DocumentData* recordPtr;
MemHandle handle;
ErrTry {
/* assign doc info values for document */
handle = FindDocData( Prefs()->docName, ALL_ELEMENTS, NULL );
if ( handle != NULL ) {
recordPtr = MemHandleLock( handle );
StrNCopy( lastDocInfo.name, recordPtr->name, dmDBNameLength );
lastDocInfo.cardNo = recordPtr->cardNo;
lastDocInfo.created = recordPtr->created;
lastDocInfo.attributes = recordPtr->attributes;
lastDocInfo.size = recordPtr->size;
lastDocInfo.categories = recordPtr->categories;
lastDocInfo.location = recordPtr->location;
lastDocInfo.timestamp = recordPtr->timestamp;
if ( lastDocInfo.location != RAM ) {
UInt16 fileLength;
ReleaseLastDocInfo();
fileLength = StrLen( recordPtr->data ) + 1;
lastDocInfo.filename = SafeMemPtrNew( fileLength );
StrNCopy( lastDocInfo.filename, recordPtr->data,
fileLength );
lastDocInfo.volumeRef = FindVolRefNum( recordPtr->data +
fileLength );
}
MemHandleUnlock( handle );
CloseRecord( handle, false );
CloseDocList();
docInfo = &lastDocInfo;
}
}
ErrCatch( UNUSED_PARAM( err ) ) {
} ErrEndCatch
CloseDocList();
}
示例6: SetFieldFromInt
void SetFieldFromInt ( UInt16 fieldID, int data ) {
/* Temporary place in heap in order to store the string data */
MemHandle txtH;
txtH = MemHandleNew ( 10 );
if ( !txtH) return;
StrPrintF ( MemHandleLock(txtH), "%i", data);
SetFieldFromHandle ( fieldID, txtH);
MemHandleUnlock (txtH);
}
示例7: GetFileProperties
/*Returns the File record associated to an vfs fileRef */
Int32 GetFileProperties (FileRef fileRef, file_rec_t* axxFileRec)
{
Int16 i;
file_rec_t* axxFileList;
i = GetFilePos((Int16)fileRef) ;
if (i == -1)
return expErrNotOpen;
axxFileList = MemHandleLock(axxFileListHandle);
MemMove (axxFileRec, &axxFileList[i],sizeof(file_rec_t));
MemHandleUnlock(axxFileListHandle);
return errNone;
}
示例8: writeRecord
/********************************************************************
* Function: addRecord
* Description: function responsible for writing a packed System record
* to the database.
* ******************************************************************/
void writeRecord (MemPtr record, MemHandle recordDBrec) {
UInt16 length = 0, offset = 0;
Char *ch;
/* get length of the system buffer */
length = MemPtrSize (record);
/* re-size and write. */
if (MemHandleResize (recordDBrec, length) == 0) {
ch = MemHandleLock (recordDBrec);
DmWrite (ch, offset, record, length);
MemHandleUnlock (recordDBrec);
}
}
示例9: SetFieldTextFromStr
/* SetFieldTextFromStr -- Fills a field with a string
* Args:
* Word fieldID -- ID of field to fill, see cwimp.rpc file
* CharPtr strP -- String to fill ID with
* Returns:
* FieldPtr -- Ptr to the field set.
*/
FieldPtr SetFieldTextFromStr(Word fieldID, CharPtr strP)
{
VoidHand txtH;
txtH = MemHandleNew(StrLen(strP) + 1);
if(!txtH) return NULL;
StrCopy(MemHandleLock(txtH), strP);
// ToDo: SetFieldTextFromHandle should happen *before* unlock
MemHandleUnlock(txtH);
return SetFieldTextFromHandle(fieldID, txtH);
}
示例10: WinDrawBitmap
void Graphics::drawBitmap(uint_t bitmapId, const Point& topLeft)
{
MemHandle handle=DmGet1Resource(bitmapRsc, bitmapId);
if (handle)
{
BitmapType* bmp=static_cast<BitmapType*>(MemHandleLock(handle));
if (bmp)
{
WinDrawBitmap(bmp, topLeft.x, topLeft.y);
MemHandleUnlock(handle);
}
DmReleaseResource(handle);
}
}
示例11: String_Done
void String_Done()
{
MemHandle *i;
context* p = Context();
StringFree();
for (i=ARRAYBEGIN(p->StrModule,MemHandle);i!=ARRAYEND(p->StrModule,MemHandle);++i)
{
MemHandleUnlock(*i);
DmReleaseResource(*i);
}
ArrayClear(&p->StrModule);
}
示例12: AppendField
int AppendField( FieldPtr fld, CharPtr str, UInt len )
{
Err err=0;
CharPtr s;
VoidHand h;
UInt prevlen;
h=(VoidHand)FldGetTextHandle(fld);
if(h==NULL) {
h=MemHandleNew(len+1);
if(h==NULL) return(-1);
s=MemHandleLock(h);
StrNCopy(s, str, len);
s[len]=0;
MemHandleUnlock(h);
} else {
prevlen=FldGetTextLength(fld);
FldSetTextHandle(fld, NULL);
if( MemHandleSize(h)<=(prevlen+len)) {
err=MemHandleResize( h, prevlen+len+1 );
}
if( err!=0 ) return(-1);
s=MemHandleLock(h);
StrNCopy(s+prevlen, str, len);
s[len+prevlen]=0;
MemHandleUnlock(h);
}
FldSetTextHandle(fld, (Handle)h);
/* FldDrawField(fld); */
return( 0 );
}
示例13: GadgetDrawWeekdays
/*****************************************************************************
* Function: GadgetDrawWeekdays
*
* Description: Draws the weekdays, extra function since called in
* GadgetDrawTimeline
*****************************************************************************/
void
GadgetDrawWeekdays(void)
{
UInt8 i;
MemHandle mh;
Char *text;
RGBColorType color, prevColor;
DateTimeType now;
Int16 dow;
RectangleType bounds, rect;
UInt16 gadgetIndex;
// Get info about Gadget
gadgetIndex = FrmGetObjectIndex(gForm, gGadgetID);
FrmGetObjectBounds(gForm, gadgetIndex, &bounds);
// Initialize time constants
TimSecondsToDateTime(TimGetSeconds(), &now);
dow = DayOfWeek(now.month, now.day, now.year);
RctSetRectangle(&rect, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y,
130, FntLineHeight()+2);
// Erase background
WinEraseRectangle(&rect, 0);
for (i=0; i < gGadgetDaysNum; ++i) {
Int16 leftoff;
mh = DmGetResource(strRsc, GADGET_STRINGS_WDAYSTART+i);
text = MemHandleLock(mh);
leftoff = (gGadgetDaysWidth+2 - FntLineWidth(text, MemPtrSize(text))) / 2;
if (TNisColored() && (dow == i+1)) {
color.r = 0xFF; color.g = 0x00; color.b = 0x00;
TNSetTextColorRGB(&color, &prevColor);
}
WinDrawChars(text, StrLen(text), bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+i+leftoff+2, bounds.topLeft.y);
if (dow == i+1) {
if (TNisColored()) {
TNSetTextColorRGB(&prevColor, NULL);
} else {
// Draw some kind of underline to determine current day
Int16 lineWidth=FntLineWidth(text, StrLen(text));
WinDrawLine(rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1, rect.topLeft.y+FntLineHeight(),
rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1+lineWidth, rect.topLeft.y+FntLineHeight());
}
}
MemHandleUnlock(mh);
}
}
示例14: CourseGetIndex
Boolean
CourseGetIndex(DmOpenRef cats, UInt16 category, UInt16 courseID, UInt16 *index)
{
MemHandle m;
*index = 0;
while ((m = DmQueryNextInCategory(cats, index, category)) != NULL) {
Char *s=(Char *)MemHandleLock(m);
if (s[0] == TYPE_COURSE) {
CourseDBRecord c;
UnpackCourse(&c, s);
if (c.id == courseID) {
// Found it!
MemHandleUnlock(m);
return true;
}
}
MemHandleUnlock(m);
*index += 1;
}
return false;
}
示例15: getSystemFromIndex
/**************************************************************************
* Function: getSystemFromIndex
* Description: based upon a system database index, this will locate the
* system for that index, unpack and decrypt it and initialize s
* ************************************************************************/
void getSystemFromIndex (DmOpenRef SystemDB, md_hash * SysPass, UInt16 index, MemHandle tmp, System * s) {
MemHandle rec = DmQueryRecord (SystemDB, index);
if (rec) {
MemPtr scratch, buff = MemHandleLock (rec);
/* resize the buffer */
if (MemHandleResize (tmp, MemPtrSize (buff)) == 0) {
scratch = MemHandleLock (tmp);
/* unpack and decrypt the account */
UnpackSystem (s, buff, scratch, SysPass, MemHandleSize (rec), true);
}
MemHandleUnlock (rec);
}
}