mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 22:02:49 -06:00
.examples Fix AndroidMath MemoryManger class
git-svn-id: svn://ultimatepp.org/upp/trunk@9573 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d93859a302
commit
c0ccc87f10
7 changed files with 94 additions and 51 deletions
|
|
@ -5,6 +5,23 @@ package org.upp.AndroidMath;
|
|||
*/
|
||||
public class Vector
|
||||
{
|
||||
/**
|
||||
* Field use by MemoryManager to stroe pointer to c++ object.
|
||||
* If you want to use MemoryManager with your class make usre you have this field
|
||||
* in your class.
|
||||
*/
|
||||
private long nativeAdress = 0;
|
||||
|
||||
/**
|
||||
* We override finalize method, beacuse we need to destroy native c++ object.
|
||||
*/
|
||||
@Override
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
nativeFinalize();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
public Vector(int size)
|
||||
{
|
||||
construct(size);
|
||||
|
|
@ -15,16 +32,6 @@ public class Vector
|
|||
copyConstruct(vec);
|
||||
}
|
||||
|
||||
/**
|
||||
* We override finalize method due to possibilite of memory leaks.
|
||||
*/
|
||||
@Override
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
destroy();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
// Native stuff - C/C++
|
||||
public native int getSize();
|
||||
public native float get(int id);
|
||||
|
|
@ -37,11 +44,5 @@ public class Vector
|
|||
|
||||
private native void construct(int size);
|
||||
private native void copyConstruct(Vector vec);
|
||||
private native void destroy();
|
||||
|
||||
static {
|
||||
// In this place we are loading native libraries.
|
||||
// Native library always has upp package name!
|
||||
System.loadLibrary("AndroidMath");
|
||||
}
|
||||
private native void nativeFinalize();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue