From be6a37df06220b62204e7be13b138dd79c9c36a7 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Thu, 15 Apr 2010 09:36:30 +0000 Subject: [PATCH] v1: introduce INVALID_FILEPOS_T to return error values when trying to read/write (only in EbmlVoid::ReplaceWidth for now) git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@121 a6f86f6d-0131-4f8e-9e7b-e335508773d5 --- ebml/EbmlElement.h | 4 ++++ src/EbmlVoid.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ebml/EbmlElement.h b/ebml/EbmlElement.h index 06fa39b..62ed7c5 100644 --- a/ebml/EbmlElement.h +++ b/ebml/EbmlElement.h @@ -238,6 +238,10 @@ extern const EbmlSemanticContext Context_EbmlGlobal; #define EBML_CTX_IDX_INFO(c,i) (c).MyTable[(i)].GetCallbacks #endif +#if !defined(INVALID_FILEPOS_T) +#define INVALID_FILEPOS_T 0 +#endif + #define EBML_DEF_CONS #define EBML_DEF_SEP #define EBML_DEF_PARAM diff --git a/src/EbmlVoid.cpp b/src/EbmlVoid.cpp index 28564bf..60354d1 100644 --- a/src/EbmlVoid.cpp +++ b/src/EbmlVoid.cpp @@ -65,11 +65,11 @@ uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output EltToReplaceWith.UpdateSize(bKeepIntact); if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) { // the element can't be written here ! - return 0; + return INVALID_FILEPOS_T; } if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() == 1) { // there is not enough space to put a filling element - return 0; + return INVALID_FILEPOS_T; } uint64 CurrentPosition = output.getFilePointer();