This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Defining arrays...



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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]