@@ -53,8 +53,50 @@ extern "C" {
5353#undef MAX
5454#define MIN (a ,b ) ((a)<(b) ? (a) : (b))
5555#define MAX (a ,b ) ((a)>(b) ? (a) : (b))
56- #define CHECK_F (f ) { size_t const errcod = f; if (ERR_isError(errcod)) return errcod; } /* check and Forward error code */
57- #define CHECK_E (f , e ) { size_t const errcod = f; if (ERR_isError(errcod)) return ERROR(e); } /* check and send Error code */
56+
57+ /**
58+ * Return the specified error if the condition evaluates to true.
59+ *
60+ * In debug modes, prints additional information. In order to do that
61+ * (particularly, printing the conditional that failed), this can't just wrap
62+ * RETURN_ERROR().
63+ */
64+ #define RETURN_ERROR_IF (cond , err , ...) \
65+ if (cond) { \
66+ RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", __FILE__, __LINE__, ZSTD_QUOTE(cond), ZSTD_QUOTE(ERROR(err))); \
67+ RAWLOG(3, ": " __VA_ARGS__); \
68+ RAWLOG(3, "\n"); \
69+ return ERROR(err); \
70+ }
71+
72+ /**
73+ * Unconditionally return the specified error.
74+ *
75+ * In debug modes, prints additional information.
76+ */
77+ #define RETURN_ERROR (err , ...) \
78+ do { \
79+ RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", __FILE__, __LINE__, ZSTD_QUOTE(ERROR(err))); \
80+ RAWLOG(3, ": " __VA_ARGS__); \
81+ RAWLOG(3, "\n"); \
82+ return ERROR(err); \
83+ } while(0);
84+
85+ /**
86+ * If the provided expression evaluates to an error code, returns that error code.
87+ *
88+ * In debug modes, prints additional information.
89+ */
90+ #define FORWARD_IF_ERROR (err , ...) \
91+ do { \
92+ size_t const err_code = (err); \
93+ if (ERR_isError(err_code)) { \
94+ RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", __FILE__, __LINE__, ZSTD_QUOTE(err), ERR_getErrorName(err_code)); \
95+ RAWLOG(3, ": " __VA_ARGS__); \
96+ RAWLOG(3, "\n"); \
97+ return err_code; \
98+ } \
99+ } while(0);
58100
59101
60102/*-*************************************
@@ -200,6 +242,17 @@ typedef struct {
200242 U32 longLengthPos ;
201243} seqStore_t ;
202244
245+ /**
246+ * Contains the compressed frame size and an upper-bound for the decompressed frame size.
247+ * Note: before using `compressedSize`, check for errors using ZSTD_isError().
248+ * similarly, before using `decompressedBound`, check for errors using:
249+ * `decompressedBound != ZSTD_CONTENTSIZE_ERROR`
250+ */
251+ typedef struct {
252+ size_t compressedSize ;
253+ unsigned long long decompressedBound ;
254+ } ZSTD_frameSizeInfo ; /* decompress & legacy */
255+
203256const seqStore_t * ZSTD_getSeqStore (const ZSTD_CCtx * ctx ); /* compress & dictBuilder */
204257void ZSTD_seqToCodes (const seqStore_t * seqStorePtr ); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
205258
0 commit comments