title: Java equivalent of C code
body: <p>I am porting a library that manipulates raw byte data in the form of a .vxl file from C to Java. In C a function is passed a "unsigned char *". What type would be best to use in Java? (Byte[]?)</p>
  
  <p>Also, why does the C code access the "unsigned char *" as an array at places although it isn't defined as it?</p>
  
  <p>Code:</p>
  
  <pre><code>    MapData * load_vxl(unsigned char * v)
      {
         MapData * map = new MapData;
         if (v == NULL)
          return map;
         int x,y,z;
         for (y=0; y &lt; 512; ++y) {
            for (x=0; x &lt; 512; ++x) {
               for (z=0; z &lt; 64; ++z) {
                  map-&gt;geometry[get_pos(x, y, z)] = 1;
               }
               z = 0;
               for(;;) {
                  int *color;
                  int i;
                  int number_4byte_chunks = v[0];
                  int top_color_start = v[1];
                  int top_color_end   = v[2]; // inclusive
                  int bottom_color_start;
                  int bottom_color_end; // exclusive
                  int len_top;
                  int len_bottom;
                  for(i=z; i &lt; top_color_start; i++)
                     map-&gt;geometry[get_pos(x, y, i)] = 0;
                  color = (int *) (v+4);
                  for(z=top_color_start; z &lt;= top_color_end; z++)
                     map-&gt;colors[get_pos(x, y, z)] = *color++;
                  len_bottom = top_color_end - top_color_start + 1;
  
                  // check for end of data marker
                  if (number_4byte_chunks == 0) {
                     // infer ACTUAL number of 4-byte chunks from the length of the color data
                     v += 4 * (len_bottom + 1);
                     break;
                  }
  
                  // infer the number of bottom colors in next span from chunk length
                  len_top = (number_4byte_chunks-1) - len_bottom;
  
                  // now skip the v pointer past the data to the beginning of the next span
                  v += v[0]*4;
  
                  bottom_color_end   = v[3]; // aka air start
                  bottom_color_start = bottom_color_end - len_top;
                  for(z=bottom_color_start; z &lt; bottom_color_end; ++z) {
                     map-&gt;colors[get_pos(x, y, z)] = *color++;
                  }
               }
            }
         }
         return map;
      }
  </code></pre>