| Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* | 
 | 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 Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 16 |  | 
 | 17 | #include <stdint.h> | 
 | 18 | #include <string.h> | 
| Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 19 | #include "globals.h" | 
 | 20 | #include "logging.h" | 
 | 21 | #include "memory_region.h" | 
| Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 22 |  | 
| Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 23 | namespace art { | 
| Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 24 |  | 
 | 25 | void MemoryRegion::CopyFrom(size_t offset, const MemoryRegion& from) const { | 
| Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 26 |   CHECK(from.pointer() != NULL); | 
 | 27 |   CHECK_GT(from.size(), 0U); | 
| Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 28 |   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 Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 34 | }  // namespace art |