summaryrefslogtreecommitdiff
path: root/android/Bootstrap/src
diff options
context:
space:
mode:
Diffstat (limited to 'android/Bootstrap/src')
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java b/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
index 0e30e459ff93..670e39724aad 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
@@ -87,4 +87,14 @@ public final class DirectBufferAllocator {
// can't free buffer - leave this to the VM
return null;
}
+
+ public static ByteBuffer guardedAllocate(int size) {
+ ByteBuffer buffer = null;
+ try {
+ buffer = allocate(size);
+ } catch (OutOfMemoryError oomException) {
+ return null;
+ }
+ return buffer;
+ }
}