blob: a5c70c3b2683b49d5ee1bf93f175828e25f5c214 [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
Elliott Hughes07ed66b2012-12-12 18:34:25 -080017#include "memory_region.h"
18
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070019#include <stdint.h>
20#include <string.h>
Elliott Hughes07ed66b2012-12-12 18:34:25 -080021
22#include "base/logging.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070023#include "globals.h"
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070024
Carl Shapiro6b6b5f02011-06-21 15:05:09 -070025namespace art {
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070026
27void MemoryRegion::CopyFrom(size_t offset, const MemoryRegion& from) const {
Mathieu Chartier2cebb242015-04-21 16:50:40 -070028 CHECK(from.pointer() != nullptr);
Elliott Hughes1f359b02011-07-17 14:27:17 -070029 CHECK_GT(from.size(), 0U);
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -070030 CHECK_GE(this->size(), from.size());
31 CHECK_LE(offset, this->size() - from.size());
32 memmove(reinterpret_cast<void*>(start() + offset),
33 from.pointer(), from.size());
34}
35
Carl Shapiro6b6b5f02011-06-21 15:05:09 -070036} // namespace art