Defining arrays...
Anthony Green
green@cygnus.com
Tue Jun 15 06:58:00 GMT 1999
Simon wrote:
> natConnection.o: In function `JArray<char> type_info function':
> natConnection.cc:16: undefined reference to `__JArray type_info
> function'
> natConnection.cc:16: undefined reference to `__JArray type_info node'
Try compiling your C++ code with -fno-rtti.
> jbyteArray Connection::toJPEG(jbyteArray rgb, jint w, jint h)
> {
> register jbyte *dPtr = elements (rgb);
> if (dPtr == NULL)
> {
> cerr << "Warning - passed NULL RGB pointer to JPEG compress" << endl;
> return NULL;
> }
I recommend something like:
if (dPtr == NULL)
_Jv_Throw (new java::lang::NullPointerException);
> // Allocate an initial buffer - will be expanded as necessary by the
> // destination memory manager code
> char * storage = new char[150000];
> jpeg_memory_dest(&cinfo, &numBytes, storage, 150000);
> // Convert to a java array
> jbyteArray result = JvNewByteArray(numBytes);
> memcpy(elements(result), storage, numBytes);
Are you sure you want to use `storage' here at the end? The code
above says that the "destination memory manager" might realloc this
buffer. It doesn't seem to have a way to update the `storage' pointer
so there must be a way to request the buffer.
This is cool - be sure to let us see what you get working in the end.
AG
--
Anthony Green Cygnus Solutions
Sunnyvale, California
More information about the Java
mailing list