strange malloc/new behavior

I have a strange problem : I'm trying to allocate simple char buffer in JNI dll with C++. But no matter what i try to write to this buffer, and how, the first 4 bytes are always = 0. I tried to allocate it with both malloc() function and new operator. Result is always the same.

Because i'm using JNI first time, and never encountered such problem before when in pure C++ development, I thought JNI may cause this.

I'll appreciate any help.

[462 byte] By [gregman_pla] at [2007-11-26 20:08:37]
# 1
How are you determining that it is zero?And it is non-sensical to say that you are using new/malloc and JNI together in terms of allocations.New/malloc is for allocations in your C++ code.JNI/java objects must be created via the appropriate java methods.
jschella at 2007-7-9 23:11:23 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

> How are you determining that it is zero?

>

simple by reading it

> And it is non-sensical to say that you are using

> new/malloc and JNI together in terms of allocations.

>

> New/malloc is for allocations in your C++ code.

> JNI/java objects must be created via the appropriate

> java methods.

no, i try create C++ char* buffer not the java object. But i do it inside JNI dll. For now i was able to make walkaround by using static array instead of allocating it dynamicly

gregman_pla at 2007-7-9 23:11:23 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
There isn't anything magical about JNI C/C++ code. It is just C/C++ code.You can certainly allocate a buffer and assign a value to it. As a guess the method you use to display the result is the actual failure point.
jschella at 2007-7-9 23:11:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...