This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: Defining arrays...
- To: simon@unique-id.com
- Subject: Re: Defining arrays...
- From: Anthony Green <green@cygnus.com>
- Date: Tue, 15 Jun 1999 06:58:31 -0700
- CC: java-discuss@sourceware.cygnus.com
- References: <37666128.9F59BDE3@unique-id.com>
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