Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp
- index e7d0a99..4912104 100644
- --- a/src/corelib/kernel/qcore_mac.cpp
- +++ b/src/corelib/kernel/qcore_mac.cpp
- @@ -66,10 +66,56 @@ QCFString::operator QString() const
- return string;
- }
- +#include <QHash>
- +QHash<const void*, int> pointerMap;
- +
- +extern QHash<const void*, int> getPointerMap() { return ::pointerMap; }
- +
- +const void *retain(const void *info)
- +{
- + qDebug("my retain");
- + pointerMap.insert(info, pointerMap.value(info)+1);
- +}
- +
- +void release(const void *info)
- +{
- + qDebug("my release");
- + pointerMap.insert(info, pointerMap.value(info)-1);
- + free(const_cast<void *>(info));
- +}
- +
- +void * myAlloc(CFIndex size, CFOptionFlags hint, void *info)
- +{
- + qDebug("my alloc");
- +// Q_ASSERT(false);
- + if (size <= 0)
- + return NULL;
- + return malloc(size);
- +}
- +
- +static CFAllocatorRef myAllocator(void) {
- + static CFAllocatorRef allocator = NULL;
- + if (!allocator) {
- + CFAllocatorContext context =
- + {0, NULL, retain, release, /*(void *)(void (*)(const void*))free,*/ NULL,
- + myAlloc,
- + NULL,
- + NULL,
- + NULL};
- + context.info = malloc(sizeof(int));
- + allocator = CFAllocatorCreate(NULL, &context);
- + }
- + return allocator;
- +}
- +
- CFStringRef QCFString::toCFStringRef(const QString &string)
- {
- - return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(string.unicode()),
- - string.length());
- + CFAllocatorRef myAllocPtr = myAllocator();
- + CFAllocatorRef myDeallocPtr = myAllocator();
- + ushort *buf = (ushort *)malloc(string.length() * sizeof(ushort));
- + memcpy(buf, reinterpret_cast<const ushort *>(string.constData()), string.length() * sizeof(ushort));
- + return CFStringCreateWithCharactersNoCopy(myAllocPtr, reinterpret_cast<const UniChar *>(buf),
- + string.length(), myDeallocPtr);
- }
- QCFString::operator CFStringRef() const
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement