Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

checksum error, help!!!



Hi,everyone.

I am using a Databrowser to list files. Users are allowed to rename files by adding a kind of tag(i.e. myFileName.jpg ===> myFileName_REG.jpg). If only one file is selected in the Databrowser, it works fine. If two or more are selected, it crashes and says "checksum error,a freed object may be modified after released". I wonder if I am using CFStringRef object and CFMutableStringRef object rightly. Can anybody give me some suggestions?

Thanks in advance.


Here is the code:

int addTag(Str31 tagStr )

{

ControlRef browser = GetDataBrowserFromWindow(window);
UInt32 selectionCount;
DataBrowserItemID itemID;
CFRange rangeToReplace;
int i;

// get the number of the selected files
int selectionCount = ........;

// allocate memory
DataBrowserItemID *myItems = malloc(sizeof(DataBrowserItemID)*selectionCount);

// get the DataBrowser item id list
myItems = ......;

for(i = 0; i < selectionCount; i++)
{
// get a item id from the item list
itemID = ....... ;

// get the file name
Str255 fileName = .......;

CFStringRef nameString = CFStringCreateWithPascalString(kCFAllocatorDefault, fileName, kCFStringEncodingMacRoman);

CFMutableStringRef mutableNameString= CFStringCreateMutableCopy(kCFAllocatorDefault, 0, nameString );

CFRelease(nameString);

CFStringInsert(mutableNameString,CFStringGetLength(mutableNameString), tagStr);

CFStringGetPascalString(mutableNameString,fileName,sizeof(fileName),kCFStringEncodingMacRoman);

CFRelease(mutableNameString);

}

CFRelease(tagStr);

UpdateDataBrowserItems(browser,kDataBrowserNoItem,selectionCount,myItems, kFileColumn, kFileColumn);

free(myItems);


}
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.