Files
android_development/ndk/tests/dlclose-destruction/jni/libtest1.cpp
David 'Digit' Turner d155de2400 Update API level 9 sysroot to allow static C++ destructors to be called on dlclose().
This introduces crtbegin_so.o and crtend_so.o and also requires a corresponding
change in the NDK build scripts to use them.

Also add a small test under 'tests/dlclose-destruction' to check that.
Note that this is not a sample (i.e. Android application) per se.

Change-Id: Icf25836363a3ed59310e579ce990aeca868e70e4
2010-06-25 16:17:58 -07:00

32 lines
379 B
C++

#include <stddef.h>
#include "libtest1.h"
class Foo
{
public:
Foo() { mAddress = NULL; }
void setAddress(int *px);
~Foo();
private:
int *mAddress;
};
void Foo::setAddress(int *px)
{
mAddress = px;
*mAddress = 1;
}
Foo::~Foo()
{
if (mAddress)
*mAddress = 2;
}
static Foo foo;
extern "C" void test1_set(int *px)
{
foo.setAddress(px);
}