VirtualBox

Ignore:
Timestamp:
Sep 4, 2014 5:24:21 PM (10 years ago)
Author:
vboxsync
Message:

3D: darwin host: fix a few memory leaks, objects initialization issues and reference counting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m

    r52560 r52598  
    369369- (id)initWithObject:(id)aObject selector:(SEL)aSelector arg:(id)aArg
    370370{
    371     [aObject retain];
    372     m_Object = aObject;
    373     m_Selector = aSelector;
    374     if (aArg != nil)
    375         [aArg retain];
    376     m_Arg = aArg;
    377    
     371    self = [super init];
     372
     373    if (self)
     374    {
     375        [aObject retain];
     376        m_Object = aObject;
     377        m_Selector = aSelector;
     378        if (aArg != nil)
     379            [aArg retain];
     380        m_Arg = aArg;
     381    }
     382
    378383    return self;
    379384}
     
    389394    if (m_Arg != nil)
    390395        [m_Arg release];
     396
     397    [super dealloc];
    391398}
    392399@end
     
    395402- (id)init
    396403{
    397     int rc = RTCritSectInit(&m_Lock);
    398     if (!RT_SUCCESS(rc))
    399     {
    400         DEBUG_WARN(("RTCritSectInit failed %d\n", rc));
    401         return nil;
    402     }
    403 
    404     m_CurIndex = 0;
    405    
    406     m_pArray = [[NSMutableArray alloc] init];
     404    self = [super init];
     405
     406    if (self)
     407    {
     408        int rc = RTCritSectInit(&m_Lock);
     409        if (!RT_SUCCESS(rc))
     410        {
     411            DEBUG_WARN(("RTCritSectInit failed %d\n", rc));
     412            return nil;
     413        }
     414
     415        m_CurIndex = 0;
     416
     417        m_pArray = [[NSMutableArray alloc] init];
     418    }
     419
    407420    return self;
    408421}
     
    410423- (void)add:(VBoxTask*)pTask
    411424{
    412     [pTask retain];
    413425    int rc = RTCritSectEnter(&m_Lock);
    414426    if (RT_SUCCESS(rc))
     
    477489    [m_pArray release];
    478490    RTCritSectDelete(&m_Lock);
     491
     492    [super dealloc];
    479493}
    480494@end
     
    548562    VBoxTaskPerformSelector *pSelTask = [[VBoxTaskPerformSelector alloc] initWithObject:aObject selector:aSelector arg:aArg];
    549563    [self add:pSelTask];
    550     [pSelTask release];
    551564}
    552565
     
    590603{
    591604    [m_pTasks release];
     605    [super dealloc];
    592606}
    593607
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette