Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Duplicating array in C code

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Duplicating array in C code

    I have a piece of Java code that passes an array of floats to a C++ library and would like to be able to have the C++ code just access the data through a pointer rather than needing to duplicate the array in memory before accessing it.
    Right now I am passing it in as a jfloatarray type and copying it over to a array of floats by doing the following in my C++ code.
    //jfloatarray is declared as in
    float *data;
    data = new float[size];
    env->GetFloatArrayRegion(in,0,size,data);
    I am concerned with copying the array for two reasons, the first is that its very large and storing extra copies can run me out of ram quickly, and second it seems like it would be faster to just use it in place rather than having the overhead of duplicating it.
    Thank you for the help.
    Last edited by FearTheCron; February 28th, 2011 at 02:36 PM. Reason: realized i didn't specify that the parent program is java


  2. #2
    Junior Member
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Duplicating array in C code

    try this..

    ...
    Last edited by copeg; April 7th, 2013 at 12:20 AM. Reason: spoonfed code removed

Similar Threads

  1. Char array to a String array with hex
    By fortune2k in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 20th, 2014, 01:01 PM
  2. prininting out a 4x4 array according to an order by a 1d array
    By fortune2k in forum Collections and Generics
    Replies: 7
    Last Post: November 25th, 2010, 12:54 PM
  3. 2d (4x4) array insdie a 1d array. (Block cipher)
    By fortune2k in forum Collections and Generics
    Replies: 13
    Last Post: November 23rd, 2010, 05:29 PM
  4. Need help with array code
    By n00bprogrammer in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 6th, 2010, 11:54 PM
  5. duplicating output
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: January 3rd, 2010, 01:11 AM

Tags for this Thread