|
22 | 22 | */
|
23 | 23 | #include <jni.h>
|
24 | 24 | #include <stdlib.h>
|
| 25 | +#include "jlong.h" |
25 | 26 |
|
26 | 27 | #include "points.h"
|
27 | 28 |
|
28 | 29 | JNIEXPORT jlong JNICALL Java_org_openjdk_bench_jdk_incubator_foreign_points_support_JNIPoint_allocate
|
29 | 30 | (JNIEnv *env, jclass nativePointClass) {
|
30 | 31 | Point* p = malloc(sizeof *p);
|
31 |
| - return (jlong) p; |
| 32 | + return ptr_to_jlong(p); |
32 | 33 | }
|
33 | 34 |
|
34 | 35 | JNIEXPORT void JNICALL Java_org_openjdk_bench_jdk_incubator_foreign_points_support_JNIPoint_free
|
35 | 36 | (JNIEnv *env, jclass cls, jlong thisPoint) {
|
36 |
| - free((Point*) thisPoint); |
| 37 | + free(jlong_to_ptr(thisPoint)); |
37 | 38 | }
|
38 | 39 |
|
39 | 40 | JNIEXPORT jint JNICALL Java_org_openjdk_bench_jdk_incubator_foreign_points_support_JNIPoint_getX
|
40 | 41 | (JNIEnv *env, jclass cls, jlong thisPoint) {
|
41 |
| - Point* point = (Point*) thisPoint; |
| 42 | + Point* point = jlong_to_ptr(thisPoint); |
42 | 43 | return point->x;
|
43 | 44 | }
|
44 | 45 |
|
45 | 46 | JNIEXPORT void JNICALL Java_org_openjdk_bench_jdk_incubator_foreign_points_support_JNIPoint_setX
|
46 | 47 | (JNIEnv *env, jclass cls, jlong thisPoint, jint value) {
|
47 |
| - Point* point = (Point*) thisPoint; |
| 48 | + Point* point = jlong_to_ptr(thisPoint); |
48 | 49 | point->x = value;
|
49 | 50 | }
|
50 | 51 |
|
51 | 52 | JNIEXPORT jint JNICALL Java_org_openjdk_bench_jdk_incubator_foreign_points_support_JNIPoint_getY
|
52 | 53 | (JNIEnv *env, jclass cls, jlong thisPoint) {
|
53 |
| - Point* point = (Point*) thisPoint; |
| 54 | + Point* point = jlong_to_ptr(thisPoint); |
54 | 55 | return point->y;
|
55 | 56 | }
|
56 | 57 |
|
57 | 58 | JNIEXPORT void JNICALL Java_org_openjdk_bench_jdk_incubator_foreign_points_support_JNIPoint_setY
|
58 | 59 | (JNIEnv *env, jclass cls, jlong thisPoint, jint value) {
|
59 |
| - Point* point = (Point*) thisPoint; |
| 60 | + Point* point = jlong_to_ptr(thisPoint); |
60 | 61 | point->y = value;
|
61 | 62 | }
|
0 commit comments