IOSAD-72 rename to PEPAutoPointer, docs
authorDirk Zimmermann <dirk@pep-project.org>
Thu, 12 Apr 2018 07:15:40 +0200
changeset 5649eba9cef4911
parent 563 dc4dab1c4a45
child 565 9ff3a0bfc8f6
IOSAD-72 rename to PEPAutoPointer, docs
pEpObjCAdapter.xcodeproj/project.pbxproj
pEpObjCAdapter/PEPAutoFree.h
pEpObjCAdapter/PEPAutoFree.m
pEpObjCAdapter/PEPAutoPointer.h
pEpObjCAdapter/PEPAutoPointer.m
pEpObjCAdapter/PEPInternalSession.m
     1.1 --- a/pEpObjCAdapter.xcodeproj/project.pbxproj	Thu Apr 12 07:15:39 2018 +0200
     1.2 +++ b/pEpObjCAdapter.xcodeproj/project.pbxproj	Thu Apr 12 07:15:40 2018 +0200
     1.3 @@ -31,7 +31,7 @@
     1.4  		43368540203D5CEC0069A451 /* PEPTestSyncDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D3D77F2010E20400A0DA20 /* PEPTestSyncDelegate.m */; };
     1.5  		433E28911FA741DE00E359B3 /* PEPIdentity.m in Sources */ = {isa = PBXBuildFile; fileRef = 433E28901FA741DE00E359B3 /* PEPIdentity.m */; };
     1.6  		434226811D4F60000083ED79 /* PepTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 434226801D4F60000083ED79 /* PepTests.m */; };
     1.7 -		434ED6D6207E27B8000A7590 /* PEPAutoFree.m in Sources */ = {isa = PBXBuildFile; fileRef = 434ED6D5207E27B8000A7590 /* PEPAutoFree.m */; };
     1.8 +		434ED6D6207E27B8000A7590 /* PEPAutoPointer.m in Sources */ = {isa = PBXBuildFile; fileRef = 434ED6D5207E27B8000A7590 /* PEPAutoPointer.m */; };
     1.9  		435796E31FB5E51A00395A9E /* PEPMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 435796E21FB5E51A00395A9E /* PEPMessage.m */; };
    1.10  		43676B661C57EA1A00233933 /* B623F674_sec.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43676B641C57EA1A00233933 /* B623F674_sec.asc */; };
    1.11  		43D27DE61F5DA7B700795687 /* NSDictionary+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 43D27DE51F5DA7B700795687 /* NSDictionary+Extension.m */; };
    1.12 @@ -157,8 +157,8 @@
    1.13  		433E288F1FA741DE00E359B3 /* PEPIdentity.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPIdentity.h; sourceTree = "<group>"; };
    1.14  		433E28901FA741DE00E359B3 /* PEPIdentity.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPIdentity.m; sourceTree = "<group>"; };
    1.15  		434226801D4F60000083ED79 /* PepTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PepTests.m; sourceTree = "<group>"; };
    1.16 -		434ED6D4207E27B8000A7590 /* PEPAutoFree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPAutoFree.h; sourceTree = "<group>"; };
    1.17 -		434ED6D5207E27B8000A7590 /* PEPAutoFree.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPAutoFree.m; sourceTree = "<group>"; };
    1.18 +		434ED6D4207E27B8000A7590 /* PEPAutoPointer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPAutoPointer.h; sourceTree = "<group>"; };
    1.19 +		434ED6D5207E27B8000A7590 /* PEPAutoPointer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPAutoPointer.m; sourceTree = "<group>"; };
    1.20  		435796E11FB5E51A00395A9E /* PEPMessage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPMessage.h; sourceTree = "<group>"; };
    1.21  		435796E21FB5E51A00395A9E /* PEPMessage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPMessage.m; sourceTree = "<group>"; };
    1.22  		43676B631C57EA1A00233933 /* 0xB623F674.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 0xB623F674.asc; sourceTree = "<group>"; };
    1.23 @@ -303,8 +303,8 @@
    1.24  				435796E21FB5E51A00395A9E /* PEPMessage.m */,
    1.25  				43DED784203C25E200D45CD6 /* NSError+PEP.h */,
    1.26  				43DED785203C25E200D45CD6 /* NSError+PEP.m */,
    1.27 -				434ED6D4207E27B8000A7590 /* PEPAutoFree.h */,
    1.28 -				434ED6D5207E27B8000A7590 /* PEPAutoFree.m */,
    1.29 +				434ED6D4207E27B8000A7590 /* PEPAutoPointer.h */,
    1.30 +				434ED6D5207E27B8000A7590 /* PEPAutoPointer.m */,
    1.31  			);
    1.32  			path = pEpObjCAdapter;
    1.33  			sourceTree = "<group>";
    1.34 @@ -477,7 +477,7 @@
    1.35  				435796E31FB5E51A00395A9E /* PEPMessage.m in Sources */,
    1.36  				43209B431ECC2DC0007E7E2E /* PEPInternalSession.m in Sources */,
    1.37  				43209B3F1ECC2DB0007E7E2E /* PEPLanguage.m in Sources */,
    1.38 -				434ED6D6207E27B8000A7590 /* PEPAutoFree.m in Sources */,
    1.39 +				434ED6D6207E27B8000A7590 /* PEPAutoPointer.m in Sources */,
    1.40  				43209B401ECC2DB4007E7E2E /* PEPMessageUtil.m in Sources */,
    1.41  				43209B3D1ECC2DA7007E7E2E /* NSArray+Extension.m in Sources */,
    1.42  				43209B3E1ECC2DAB007E7E2E /* PEPCSVScanner.m in Sources */,
     2.1 --- a/pEpObjCAdapter/PEPAutoFree.h	Thu Apr 12 07:15:39 2018 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,21 +0,0 @@
     2.4 -//
     2.5 -//  PEPAutoFree.h
     2.6 -//  pEpObjCAdapter
     2.7 -//
     2.8 -//  Created by Dirk Zimmermann on 11.04.18.
     2.9 -//  Copyright © 2018 p≡p. All rights reserved.
    2.10 -//
    2.11 -
    2.12 -#import <Foundation/Foundation.h>
    2.13 -
    2.14 -/**
    2.15 - Enable use of ARC (or manual cocoa memory management) for malloc-created pointers.
    2.16 - */
    2.17 -@interface PEPAutoFree : NSObject
    2.18 -
    2.19 -- (void **)voidPointerPointer;
    2.20 -- (char **)charPointerPointer;
    2.21 -- (void *)voidPointer;
    2.22 -- (char *)charPointer;
    2.23 -
    2.24 -@end
     3.1 --- a/pEpObjCAdapter/PEPAutoFree.m	Thu Apr 12 07:15:39 2018 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,44 +0,0 @@
     3.4 -//
     3.5 -//  PEPAutoFree.m
     3.6 -//  pEpObjCAdapter
     3.7 -//
     3.8 -//  Created by Dirk Zimmermann on 11.04.18.
     3.9 -//  Copyright © 2018 p≡p. All rights reserved.
    3.10 -//
    3.11 -
    3.12 -#import "PEPAutoFree.h"
    3.13 -
    3.14 -@interface PEPAutoFree ()
    3.15 -
    3.16 -@property (nonatomic) void *thePointer;
    3.17 -
    3.18 -@end
    3.19 -
    3.20 -@implementation PEPAutoFree
    3.21 -
    3.22 -- (void **)voidPointerPointer
    3.23 -{
    3.24 -    return &_thePointer;
    3.25 -}
    3.26 -
    3.27 -- (char **)charPointerPointer
    3.28 -{
    3.29 -    return (char **) self.voidPointerPointer;
    3.30 -}
    3.31 -
    3.32 -- (void *)voidPointer
    3.33 -{
    3.34 -    return self.thePointer;
    3.35 -}
    3.36 -
    3.37 -- (char *)charPointer
    3.38 -{
    3.39 -    return (char *) self.voidPointer;
    3.40 -}
    3.41 -
    3.42 -- (void)dealloc
    3.43 -{
    3.44 -    free(_thePointer);
    3.45 -}
    3.46 -
    3.47 -@end
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/pEpObjCAdapter/PEPAutoPointer.h	Thu Apr 12 07:15:40 2018 +0200
     4.3 @@ -0,0 +1,41 @@
     4.4 +//
     4.5 +//  PEPAutoPointer.h
     4.6 +//  pEpObjCAdapter
     4.7 +//
     4.8 +//  Created by Dirk Zimmermann on 11.04.18.
     4.9 +//  Copyright © 2018 p≡p. All rights reserved.
    4.10 +//
    4.11 +
    4.12 +#import <Foundation/Foundation.h>
    4.13 +
    4.14 +/**
    4.15 + Implements a very basic method to enable use of ARC (or manual cocoa memory management)
    4.16 + for malloc-created pointers.
    4.17 +
    4.18 + When this object goes out of scope (is freed), it calls free() on the contained pointer.
    4.19 + */
    4.20 +@interface PEPAutoPointer : NSObject
    4.21 +
    4.22 +/**
    4.23 + Provide this to a C-function that expects a `void **` pointer to allocate and fill.
    4.24 + */
    4.25 +- (void **)voidPointerPointer;
    4.26 +
    4.27 +/**
    4.28 + Provide this to a C-function that expects a `char **` pointer to allocate and fill.
    4.29 + */
    4.30 +- (char **)charPointerPointer;
    4.31 +
    4.32 +/**
    4.33 + When you have used some C-function to receive content,
    4.34 + use this to access it as a `void *` pointer.
    4.35 + */
    4.36 +- (void *)voidPointer;
    4.37 +
    4.38 +/**
    4.39 + When you have used some C-function to receive content,
    4.40 + use this to access it as a `char *` pointer.
    4.41 + */
    4.42 +- (char *)charPointer;
    4.43 +
    4.44 +@end
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/pEpObjCAdapter/PEPAutoPointer.m	Thu Apr 12 07:15:40 2018 +0200
     5.3 @@ -0,0 +1,44 @@
     5.4 +//
     5.5 +//  PEPAutoPointer.m
     5.6 +//  pEpObjCAdapter
     5.7 +//
     5.8 +//  Created by Dirk Zimmermann on 11.04.18.
     5.9 +//  Copyright © 2018 p≡p. All rights reserved.
    5.10 +//
    5.11 +
    5.12 +#import "PEPAutoPointer.h"
    5.13 +
    5.14 +@interface PEPAutoPointer ()
    5.15 +
    5.16 +@property (nonatomic) void *thePointer;
    5.17 +
    5.18 +@end
    5.19 +
    5.20 +@implementation PEPAutoPointer
    5.21 +
    5.22 +- (void **)voidPointerPointer
    5.23 +{
    5.24 +    return &_thePointer;
    5.25 +}
    5.26 +
    5.27 +- (char **)charPointerPointer
    5.28 +{
    5.29 +    return (char **) self.voidPointerPointer;
    5.30 +}
    5.31 +
    5.32 +- (void *)voidPointer
    5.33 +{
    5.34 +    return self.thePointer;
    5.35 +}
    5.36 +
    5.37 +- (char *)charPointer
    5.38 +{
    5.39 +    return (char *) self.voidPointer;
    5.40 +}
    5.41 +
    5.42 +- (void)dealloc
    5.43 +{
    5.44 +    free(_thePointer);
    5.45 +}
    5.46 +
    5.47 +@end
     6.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Thu Apr 12 07:15:39 2018 +0200
     6.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Thu Apr 12 07:15:40 2018 +0200
     6.3 @@ -17,7 +17,7 @@
     6.4  #import "PEPIdentity.h"
     6.5  #import "PEPMessage.h"
     6.6  #import "NSError+PEP.h"
     6.7 -#import "PEPAutoFree.h"
     6.8 +#import "PEPAutoPointer.h"
     6.9  
    6.10  @implementation PEPInternalSession
    6.11  
    6.12 @@ -435,7 +435,7 @@
    6.13          unsigned int value;
    6.14          [[NSScanner scannerWithString:str] scanHexInt:&value];
    6.15  
    6.16 -        PEPAutoFree *word = [PEPAutoFree new];
    6.17 +        PEPAutoPointer *word = [PEPAutoPointer new];
    6.18          size_t size;
    6.19  
    6.20          PEP_STATUS status = trustword(_session,
    6.21 @@ -620,7 +620,7 @@
    6.22      pEp_identity *ident2 = PEP_identityToStruct(identity2);
    6.23      PEP_STATUS status;
    6.24  
    6.25 -    PEPAutoFree *trustwords = [PEPAutoFree new];
    6.26 +    PEPAutoPointer *trustwords = [PEPAutoPointer new];
    6.27      size_t sizeWritten = 0;
    6.28  
    6.29      [self lockWrite];
    6.30 @@ -642,7 +642,7 @@
    6.31  
    6.32  - (NSArray<PEPLanguage *> * _Nullable)languageListWithError:(NSError * _Nullable * _Nullable)error
    6.33  {
    6.34 -    PEPAutoFree *chLangs = [PEPAutoFree new];
    6.35 +    PEPAutoPointer *chLangs = [PEPAutoPointer new];
    6.36      PEP_STATUS status = get_languagelist(_session, chLangs.charPointerPointer);
    6.37  
    6.38      if ([NSError setError:error fromPEPStatus:status]) {