Skip to content

Commit 7055f17

Browse files
committed
添加sm3对象消失时出发c程序释放内存
1 parent 709fdc2 commit 7055f17

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/main/java/org/gmssl/Sm3.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
package org.gmssl;
1111

12-
public class Sm3 {
12+
public class Sm3 implements AutoCloseable{
1313

1414
public final static int DIGEST_SIZE = GmSSLJNI.SM3_DIGEST_SIZE;
1515

@@ -57,4 +57,9 @@ public byte[] digest() {
5757
}
5858
return dgst;
5959
}
60+
61+
@Override
62+
public void close() throws Exception {
63+
GmSSLJNI.sm3_ctx_free(sm3_ctx);
64+
}
6065
}

0 commit comments

Comments
 (0)