내 앱에 간단한 stringdecompression 알고리즘을 만들려고합니다.이 zlib 문자열 압축 풀기에 어떤 문제가 있습니까?
/*
Decompresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total size
of the destination buffer, which must be large enough to hold the entire
uncompressed data. (The size of the uncompressed data must have been saved
previously by the compressor and transmitted to the decompressor by some
mechanism outside the scope of this compression library.) Upon exit, destLen
is the actual size of the uncompressed buffer.
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
*/
[Base64 initialize];
NSData * data = [Base64 decode:@"MDAwMDAwNTB42vPMVkhKzVNIBeLsnNTMPB0IpVCWWZyVqpAJkalKTVUoS8xTSMpJLC0HALWrEYi="];
NSString * deBase64 = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
int lengteOP = [[deBase64 substringWithRange:NSMakeRange(0,8)] intValue];
NSUInteger lengteIP = [deBase64 length];
const unsigned char *input = (const unsigned char *) [[deBase64 substringFromIndex:8] cStringUsingEncoding:NSASCIIStringEncoding];
unsigned char * dest;
uncompress(dest, lengteOP, input, lengteIP);
내가 이것을 시도 할 때 EXC_BADD_ACCESS 오류가 발생합니다. 문자열 아이폰 SDK
의 라이브러리와 같은 ZLIB를 사용 델파이 코드 빌드 인 그것 ZLIB 혼성 문자열 뒤에 문자열의 길이를 나타내는 제 8 개 문자 base64로 인 코드 스트링.
탱크 대단히, 나는 마침내 당신의 도움과 협력 얻었다. – user829660