Skip to content

Commit

Permalink
#75 Out of memory exception (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechRynczuk committed Mar 4, 2020
1 parent 67caefe commit d29f09b
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 4 deletions.
3 changes: 2 additions & 1 deletion sources/cmake/commonSources.cmake
Expand Up @@ -2,7 +2,7 @@
#
# List of common source files and directories.
#
# Copyright (c) 2017 vcdMaker team
# Copyright (c) 2019 vcdMaker team
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -88,6 +88,7 @@ set(COMMON_HEADERS
${COMMON_HEADERS_DIR}/VCDTracer.h
${COMMON_HEADERS_DIR}/SafeUInt.h
${COMMON_HEADERS_DIR}/Timestamp.h
${COMMON_HEADERS_DIR}/OutOfMemory.h
${VERSION_HEADER})

# 3rd party directories.
Expand Down
Binary file modified sources/common/doc/manual.odt
Binary file not shown.
Binary file modified sources/common/doc/manual.pdf
Binary file not shown.
37 changes: 37 additions & 0 deletions sources/common/inc/OutOfMemory.h
@@ -0,0 +1,37 @@
/// @file common/inc/OutOfMemory.h
///
/// The common out of memory handler.
///
/// @par Full Description
/// The common out of memory handler to be used by vcdMaker and vcdMerge.
///
/// @ingroup Exception
///
/// @par Copyright (c) 2019 vcdMaker team
///
/// Permission is hereby granted, free of charge, to any person obtaining a
/// copy of this software and associated documentation files (the "Software"),
/// to deal in the Software without restriction, including without limitation
/// the rights to use, copy, modify, merge, publish, distribute, sublicense,
/// and/or sell copies of the Software, and to permit persons to whom the
/// Software is furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included
/// in all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
/// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
/// IN THE SOFTWARE.

#pragma once

#include "VcdException.h"

inline void OutOfMemory()
{
throw EXCEPTION::VcdException(EXCEPTION::Error::OUT_OF_MEMORY, "Out of memory.");
}
5 changes: 4 additions & 1 deletion sources/common/inc/VcdExceptionList.h
Expand Up @@ -8,7 +8,7 @@
///
/// @ingroup Exception
///
/// @par Copyright (c) 2018 vcdMaker team
/// @par Copyright (c) 2019 vcdMaker team
///
/// Permission is hereby granted, free of charge, to any person obtaining a
/// copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -120,6 +120,9 @@ namespace EXCEPTION
/// Vector size exceeded.
const uint32_t VECTOR_SIZE_EXCEEDED = 21U;

/// Out of memory.
const uint32_t OUT_OF_MEMORY = 22U;

// Logic errors below shall never happen.
// They are enumerated from 9000.

Expand Down
5 changes: 4 additions & 1 deletion sources/vcdMaker/src/vcdMaker.cpp
Expand Up @@ -2,7 +2,7 @@
///
/// The main module of the vcdMaker application.
///
/// @par Copyright (c) 2018 vcdMaker team
/// @par Copyright (c) 2019 vcdMaker team
///
/// Permission is hereby granted, free of charge, to any person obtaining a
/// copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -33,6 +33,7 @@
#include "Logger.h"
#include "XmlSignalFactory.h"
#include "DefaultSignalFactory.h"
#include "OutOfMemory.h"

/// The vcdMaker main function.
///
Expand All @@ -44,6 +45,8 @@ int main(int argc, const char *argv[])
// The application execution status.
int32_t executionStatus = EXECUTION::APP_OK;

std::set_new_handler(OutOfMemory);

try
{
// Parse input parameters
Expand Down
5 changes: 4 additions & 1 deletion sources/vcdMerge/src/vcdMerge.cpp
Expand Up @@ -2,7 +2,7 @@
///
/// The main module of the vcdMerge application.
///
/// @par Copyright (c) 2018 vcdMaker team
/// @par Copyright (c) 2019 vcdMaker team
///
/// Permission is hereby granted, free of charge, to any person obtaining a
/// copy of this software and associated documentation files (the "Software"),
Expand All @@ -29,6 +29,7 @@
#include "SignalSource.h"
#include "Merge.h"
#include "Logger.h"
#include "OutOfMemory.h"

/// The vcdMerge main function.
///
Expand All @@ -40,6 +41,8 @@ int main(int argc, const char *argv[])
// The application execution status.
int32_t executionStatus = EXECUTION::APP_OK;

std::set_new_handler(OutOfMemory);

try
{
// Parse input parameters
Expand Down
1 change: 1 addition & 0 deletions windows/vcdMaker/vcdMakerCore/vcdMakerCore.vcxproj
Expand Up @@ -152,6 +152,7 @@
<ClInclude Include="..\..\..\sources\common\inc\LineCounter.h" />
<ClInclude Include="..\..\..\sources\common\inc\Logger.h" />
<ClInclude Include="..\..\..\sources\common\inc\LogParser.h" />
<ClInclude Include="..\..\..\sources\common\inc\OutOfMemory.h" />
<ClInclude Include="..\..\..\sources\common\inc\SafeUInt.h" />
<ClInclude Include="..\..\..\sources\common\inc\Signal.h" />
<ClInclude Include="..\..\..\sources\common\inc\SignalCreator.h" />
Expand Down
3 changes: 3 additions & 0 deletions windows/vcdMaker/vcdMakerCore/vcdMakerCore.vcxproj.filters
Expand Up @@ -110,6 +110,9 @@
<ClInclude Include="..\..\..\sources\common\inc\TimeUnit.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\sources\common\inc\OutOfMemory.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\sources\common\src\EventSignalCreator.cpp">
Expand Down

0 comments on commit d29f09b

Please sign in to comment.