blob: 95a2bc7c1a133912a69ca37c5751b2abb9f48d92 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "fuzz_input.h"
#include <string.h>
#include <cstddef>
#include <cstdint>
namespace fuzzing {
const uint8_t* FuzzInput::TakeBytes(size_t size) {
if (remaining_ < size) {
return nullptr;
}
const uint8_t* out = data_;
data_ += size;
remaining_ -= size;
return out;
}
bool FuzzInput::CopyBytes(uint8_t* out, size_t size) {
if (remaining_ < size || !out) {
return false;
}
memcpy(out, data_, size);
data_ += size;
remaining_ -= size;
return true;
}
} // namespace fuzzing