allocate memory problem
Hello. I have created an applet and i put it to my java card .
Iso, can write to an array but when I repeat the procedure for 15 times(after 16 ) I get an error and the status word that it returns is "6F00",
. I read somewhere that i have to allocate the memory in constructor because if i dont the memory is never free.
can you please tell me what i have to do?
my code is:
package com.acme.options;
import javacard.framework.*;
public class optionsApplet extends Applet {
final static byte Helloword_CLA = (byte) 0xB0;
final static byte WR_HELLO = (byte) 0x57;
private short i = 0;
private short a = 0;
private short x = 0;
byte[] hello=new byte[0];
byte[] hello2;
byte[] hello3;
public static void install(byte[] bArray, short bOffset, byte bLength) {
// GP-compliant JavaCard applet registration
new optionsApplet().register(bArray, (short) (bOffset + 1),
bArray[bOffset]);
}
public void process(APDU apdu) {
// Good practice: Return 9000 on SELECT
if (selectingApplet()) {
return;
}
byte[] buffer = apdu.getBuffer();
if (buffer[ISO7816.OFFSET_CLA] != Helloword_CLA)
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
switch (buffer[ISO7816.OFFSET_INS]) {
case WR_HELLO:
wr_hello(apdu);
return;
case RESET:
default:
}
}
private void wr_hello(APDU apdu) throws APDUException {
byte[] temp = apdu.getBuffer();
short data_length = (short) (temp[ISO7816.OFFSET_LC] & 0xFF);
hello2 = new byte[data_length];
short read_count = apdu.setIncomingAndReceive();
Util.arrayCopy(temp, ISO7816.OFFSET_CDATA, hello2, (short) 0,
(short) data_length);
hello3 = hello;
hello = new byte[hello3.length + hello2.length];
for (i = 0; i < hello3.length; ++i) {
hello = hello3;
}
for (i = (short) hello3.length; i < hello.length; ++i) {
hello = hello2[x];
x++;
}
i = 0;
a = 0;
x = 0;
}
}

