Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/mfast/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
// See the file license.txt for licensing information.
#include "allocator.h"
#include <new>
#include "allocator_utils.h"
#include <cstring>

namespace mfast {

inline std::size_t align(std::size_t n, std::size_t x) {
const std::size_t y = x - 1;
return (n + y) & ~y;
}

std::size_t allocator::reallocate(void *&pointer, std::size_t old_size,
std::size_t new_size) {
// make the new_size at least 64 bytes
Expand Down
11 changes: 11 additions & 0 deletions src/mfast/allocator_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include <cstddef>

namespace mfast {

inline std::size_t align(std::size_t n, std::size_t x) {
const std::size_t y = x - 1;
return (n + y) & ~y;
}

}
6 changes: 1 addition & 5 deletions src/mfast/arena_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
// This file is part of mFAST.
// See the file license.txt for licensing information.
#include "arena_allocator.h"
#include "allocator_utils.h"
#include <cstring>
#include <algorithm>
#include <cstdlib>

namespace mfast {

inline std::size_t align(std::size_t n, std::size_t x) {
const std::size_t y = x - 1;
return (n + y) & ~y;
}

void arena_allocator::free_list(memory_chunk_base *head) {
memory_chunk_base *tmp;
while (head) {
Expand Down
7 changes: 2 additions & 5 deletions src/mfast/xml_parser/FastXMLVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
// This file is part of mFAST.
// See the file license.txt for licensing information.
#include "FastXMLVisitor.h"
#include "xml_util.h"
#include <cstring>
#include <cstdlib>
#include <iostream>
const char *FastXMLVisitor::get_optional_attr(const XMLElement &element,
const char *attr_name,
const char *default_value) const {
const XMLAttribute *attr = element.FindAttribute(attr_name);
if (attr == nullptr) {
return default_value;
}
return attr->Value();
return mfast::xml_parser::get_optional_attr(element, attr_name, default_value);
}

bool FastXMLVisitor::is_mandatory_constant(const XMLElement &element) {
Expand Down
11 changes: 1 addition & 10 deletions src/mfast/xml_parser/view_info_builder.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <cstring>
#include <string.h>
#include "view_info_builder.h"
#include "xml_util.h"
#include "../exceptions.h"
#include <algorithm>
namespace mfast {
Expand Down Expand Up @@ -158,16 +159,6 @@ void view_info_builder::visit(const set_field_instruction *inst,
struct tag_reference_name;
typedef boost::error_info<tag_reference_name, std::string> reference_name_info;

inline const char *get_optional_attr(const tinyxml2::XMLElement &element,
const char *attr_name,
const char *default_value) {
const tinyxml2::XMLAttribute *attr = element.FindAttribute(attr_name);
if (attr == nullptr) {
return default_value;
}
return attr->Value();
}

void view_info_builder::build_field_view(const tinyxml2::XMLElement &element,
unsigned &max_depth,
std::deque<field_view_info> &fields) {
Expand Down
5 changes: 1 addition & 4 deletions src/mfast/xml_parser/xml_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ inline const char *get_optional_attr(const XMLElement &element,
const char *attr_name,
const char *default_value) {
const XMLAttribute *attr = element.FindAttribute(attr_name);
if (attr == nullptr) {
return default_value;
}
return attr->Value();
return attr ? attr->Value() : default_value;
}

inline const char *string_dup(const char *str, arena_allocator &alloc) {
Expand Down