Skip to content

Commit

Permalink
Namespace gzip extension class. (#585)
Browse files Browse the repository at this point in the history
See #584
  • Loading branch information
f2prateek committed Aug 5, 2016
1 parent 9dc4aa5 commit 34b7269
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 145 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//


#import "NSData+GZIP.h"
#import "NSData+SEGGZIP.h"
#import <zlib.h>
#import <dlfcn.h>

Expand All @@ -56,13 +56,13 @@ - (NSData *)seg_gzippedDataWithCompressionLevel:(float)level
if (self.length == 0 || [self seg_isGzippedData]) {
return self;
}

void *libz = seg_libzOpen();
int (*deflateInit2_)(z_streamp, int, int, int, int, int, const char *, int) =
(int (*)(z_streamp, int, int, int, int, int, const char *, int))dlsym(libz, "deflateInit2_");
(int (*)(z_streamp, int, int, int, int, int, const char *, int))dlsym(libz, "deflateInit2_");
int (*deflate)(z_streamp, int) = (int (*)(z_streamp, int))dlsym(libz, "deflate");
int (*deflateEnd)(z_streamp) = (int (*)(z_streamp))dlsym(libz, "deflateEnd");

z_stream stream;
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
Expand All @@ -71,9 +71,9 @@ - (NSData *)seg_gzippedDataWithCompressionLevel:(float)level
stream.next_in = (Bytef *)(void *)self.bytes;
stream.total_out = 0;
stream.avail_out = 0;

static const NSUInteger ChunkSize = 16384;

NSMutableData *output = nil;
int compression = (level < 0.0f) ? Z_DEFAULT_COMPRESSION : (int)(roundf(level * 9));
if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK) {
Expand All @@ -89,7 +89,7 @@ - (NSData *)seg_gzippedDataWithCompressionLevel:(float)level
deflateEnd(&stream);
output.length = stream.total_out;
}

return output;
}

Expand Down
2 changes: 1 addition & 1 deletion Analytics/Classes/Internal/SEGHTTPClient.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "SEGHTTPClient.h"
#import "NSData+GZIP.h"
#import "NSData+SEGGZIP.h"
#import "SEGAnalyticsUtils.h"


Expand Down
1 change: 0 additions & 1 deletion Analytics/Classes/Internal/SEGSegmentIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#import "SEGBluetooth.h"
#import "SEGReachability.h"
#import "SEGLocation.h"
#import "NSData+GZIP.h"
#import "SEGHTTPClient.h"

#if TARGET_OS_IOS
Expand Down
268 changes: 134 additions & 134 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Tests/SEGHTTPClientTests.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
#import <Analytics/SEGHTTPClient.h>
#import <Analytics/NSData+GZIP.h>
#import <Analytics/NSData+SEGGZIP.h>
#import <Nocilla/Nocilla.h>

SpecBegin(SEGHTTPClient);
Expand Down

0 comments on commit 34b7269

Please sign in to comment.