English 中文(简体)
静态分配的校正 图书馆的散射阵列破坏了目标C++方案
原标题:memset on a statically-allocated zlib Byte array in a library crashes an Objective-C++ program

I m 书写一个图书馆,使用一个固定地点C-array的Byte,定义是Zlib.h。 我发现,这部法典用电击 me。 完整的法典就是这样:

Byte compressedDataBuffer[kLabelBufSiz]; 
memset (compressedDataBuffer, 0, (kLabelBufSiz * sizeof(Byte)));

I tried pre-computing the value of kLabelBufSiz * sizeof(Byte) and using the numeric value for the memset, but it made no difference. This is a single-threaded program and there is no code between the two calls, so I know that the memory and pointer are not changing. I confirmed that sizeof(Byte) is 1. I tried changing the array type to char, and that stopped the crash, so it seems that the Byte type may be playing a role here.

I wrote a smaller program that calls this library function, and that one does not crash. The non-crashing program is pure C++, whereas the crashing one is Objective-C++. I m building them both on Mac OSX 10.6.7, with gcc-4.2 and XCode. Is there something about ObjC++ that could cause problems here? I ve never had problems with C++ libraries called from ObjC++ before, but that doesn t mean they don t exist. Any help is greatly appreciated!

问题回答

By是个包裹。 使用果园,而不是 by。 除非你在这种情况下使用拜特,否则不会使用过点滴。





相关问题
How to determine compressed size from zlib for gzipped data?

I m using zlib to perform gzip compression. zlib writes the data directly to an open TCP socket after compressing it. /* socket_fd is a file descriptor for an open TCP socket */ gzFile gzf = gzdopen(...

Transparent SQLite Data Compression

I am looking for an existing solution for transparent SQLite 3 zlib compression using a custom VFS implementation and a custom IO methods implementation. Is anyone aware of an existing project that ...

"Untar" file on iPhone

I m writing an iPhone app which downloads a tar-gzipped file from a Webserver, then needs to unarchive this file so that it can be copied into the app s Documents folder. I m using tar/gzip because I ...

Compress data before storage on Google App Engine

I im trying to store 30 second user mp3 recordings as Blobs in my app engine data store. However, in order to enable this feature (App Engine has a 1MB limit per upload) and to keep the costs down I ...

Unzipping part of a .gz file using python

So here s the problem. I have sample.gz file which is roughly 60KB in size. I want to decompress the first 2000 bytes of this file. I am running into CRC check failed error, I guess because the gzip ...

热门标签