Class NativeString
- java.lang.Object
-
- uk.co.caprica.vlcj.binding.NativeString
-
public final class NativeString extends Object
Encapsulation of access to native strings.This class takes care of freeing the memory that was natively allocated for the string, if needed.
Generally, any native API that returns "const char*" must not be freed, so in such cases the native return type mapping can actually be String rather than
Pointer. Alternatively,copyNativeString(Pointer)can be used.Generally, Any native API that returns "char*" must be freed, so in such cases the native return type mapping must be
PointerandcopyAndFreeNativeString(LibVlc, Pointer)must be used.Where a native string is contained in a
Structurethose strings should not be freed if the structure itself is subsequently freed (usually by a companion release native method), so in these casescopyNativeString(Pointer)must be used.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcopyAndFreeNativeString(LibVlc libvlc, com.sun.jna.Pointer pointer)Get a String from a native string pointer, freeing the native string pointer when done.static StringcopyNativeString(com.sun.jna.Pointer pointer)Copy a String from a native string pointer, without freeing the native pointer.
-
-
-
Method Detail
-
copyAndFreeNativeString
public static final String copyAndFreeNativeString(LibVlc libvlc, com.sun.jna.Pointer pointer)
Get a String from a native string pointer, freeing the native string pointer when done.If the native string pointer is not freed then a native memory leak will occur.
Use this method if the native string type is "char*", i.e. lacking the "const" modifier.
- Parameters:
libvlc- native library instancepointer- pointer to native string, may benull- Returns:
- string, or
nullif the pointer wasnull
-
copyNativeString
public static final String copyNativeString(com.sun.jna.Pointer pointer)
Copy a String from a native string pointer, without freeing the native pointer.Use this method if the native string type is "const char*".
- Parameters:
pointer- pointer to native string, may benull- Returns:
- string, or
nullif the pointer wasnull
-
-