blob: 4053efcd16a56fa0f63ea873eb645c3f74b95efa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// natCoreInputStream.cc -- C++ side of CoreInputStream
/* Copyright (C) 2001 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Anthony Green <green@redhat.com>. */
#include <config.h>
#include <gcj/cni.h>
#include <jvm.h>
#include <string.h>
#include <java/lang/NullPointerException.h>
#include <java/lang/ArrayIndexOutOfBoundsException.h>
#include <gnu/java/net/protocol/core/CoreInputStream.h>
jint
gnu::java::net::protocol::core::CoreInputStream::unsafeGetByte (jlong offset)
{
return ((char*) ptr) [offset];
}
jint
gnu::java::net::protocol::core::CoreInputStream::copyIntoByteArray (jbyteArray dest,
jint offset,
jint numBytes)
{
if (!dest)
throw new ::java::lang::NullPointerException;
jsize destSize = JvGetArrayLength (dest);
if (offset < 0 || numBytes < 0 || offset + numBytes < 0
|| offset + numBytes > destSize
|| pos + numBytes > count)
throw new ::java::lang::ArrayIndexOutOfBoundsException;
void *pcore = (void *) &((char*) ptr) [pos];
void *pdest = (void *) (elements (dest) + offset);
memcpy (pdest, pcore, numBytes);
return 0;
}
|