blob: 78cb91db55cae79df0112c411ff2497202be99c3 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070016
17#include <stdint.h>
18#include <string.h>
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070019#include "globals.h"
20#include "logging.h"
21#include "memory_region.h"
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070022
Carl Shapiro6b6b5f02011-06-21 15:05:09 -070023namespace art {
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070024
25void MemoryRegion::CopyFrom(size_t offset, const MemoryRegion& from) const {
Elliott Hughes1f359b02011-07-17 14:27:17 -070026 CHECK(from.pointer() != NULL);
27 CHECK_GT(from.size(), 0U);
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070028 CHECK_GE(this->size(), from.size());
29 CHECK_LE(offset, this->size() - from.size());
30 memmove(reinterpret_cast<void*>(start() + offset),
31 from.pointer(), from.size());
32}
33
Carl Shapiro6b6b5f02011-06-21 15:05:09 -070034} // namespace art