zstd-ruby 1.3.2.0 → 1.3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/zstdruby/libzstd/BUCK +31 -10
  4. data/ext/zstdruby/libzstd/common/bitstream.h +1 -1
  5. data/ext/zstdruby/libzstd/common/mem.h +15 -13
  6. data/ext/zstdruby/libzstd/common/pool.c +1 -2
  7. data/ext/zstdruby/libzstd/common/zstd_common.c +10 -4
  8. data/ext/zstdruby/libzstd/common/zstd_internal.h +52 -170
  9. data/ext/zstdruby/libzstd/compress/zstd_compress.c +434 -337
  10. data/ext/zstdruby/libzstd/compress/{zstd_compress.h → zstd_compress_internal.h} +191 -36
  11. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +1 -0
  12. data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +3 -2
  13. data/ext/zstdruby/libzstd/compress/zstd_fast.c +1 -0
  14. data/ext/zstdruby/libzstd/compress/zstd_fast.h +3 -2
  15. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +66 -50
  16. data/ext/zstdruby/libzstd/compress/zstd_lazy.h +3 -2
  17. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +3 -2
  18. data/ext/zstdruby/libzstd/compress/zstd_opt.c +504 -676
  19. data/ext/zstdruby/libzstd/compress/zstd_opt.h +2 -2
  20. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +130 -80
  21. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +15 -7
  22. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +41 -31
  23. data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +1 -0
  24. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +1 -1
  25. data/ext/zstdruby/libzstd/legacy/zstd_v01.c +1 -1
  26. data/ext/zstdruby/libzstd/legacy/zstd_v02.c +1 -74
  27. data/ext/zstdruby/libzstd/legacy/zstd_v03.c +1 -74
  28. data/ext/zstdruby/libzstd/legacy/zstd_v04.c +1 -72
  29. data/ext/zstdruby/libzstd/legacy/zstd_v05.c +1 -73
  30. data/ext/zstdruby/libzstd/legacy/zstd_v06.c +1 -77
  31. data/ext/zstdruby/libzstd/legacy/zstd_v07.c +1 -77
  32. data/ext/zstdruby/libzstd/zstd.h +43 -30
  33. data/lib/zstd-ruby/version.rb +1 -1
  34. metadata +4 -4
@@ -839,16 +839,6 @@ MEM_STATIC BITv06_DStream_status BITv06_reloadDStream(BITv06_DStream_t* bitD);
839
839
  MEM_STATIC unsigned BITv06_endOfDStream(const BITv06_DStream_t* bitD);
840
840
 
841
841
 
842
- /* Start by invoking BITv06_initDStream().
843
- * A chunk of the bitStream is then stored into a local register.
844
- * Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t).
845
- * You can then retrieve bitFields stored into the local register, **in reverse order**.
846
- * Local register is explicitly reloaded from memory by the BITv06_reloadDStream() method.
847
- * A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BITv06_DStream_unfinished.
848
- * Otherwise, it can be less than that, so proceed accordingly.
849
- * Checking if DStream has reached its end can be performed with BITv06_endOfDStream().
850
- */
851
-
852
842
 
853
843
  /*-****************************************
854
844
  * unsafe API
@@ -861,7 +851,7 @@ MEM_STATIC size_t BITv06_readBitsFast(BITv06_DStream_t* bitD, unsigned nbBits);
861
851
  /*-**************************************************************
862
852
  * Internal functions
863
853
  ****************************************************************/
864
- MEM_STATIC unsigned BITv06_highbit32 (register U32 val)
854
+ MEM_STATIC unsigned BITv06_highbit32 ( U32 val)
865
855
  {
866
856
  # if defined(_MSC_VER) /* Visual */
867
857
  unsigned long r=0;
@@ -929,13 +919,6 @@ MEM_STATIC size_t BITv06_initDStream(BITv06_DStream_t* bitD, const void* srcBuff
929
919
  }
930
920
 
931
921
 
932
- /*! BITv06_lookBits() :
933
- * Provides next n bits from local register.
934
- * local register is not modified.
935
- * On 32-bits, maxNbBits==24.
936
- * On 64-bits, maxNbBits==56.
937
- * @return : value extracted
938
- */
939
922
  MEM_STATIC size_t BITv06_lookBits(const BITv06_DStream_t* bitD, U32 nbBits)
940
923
  {
941
924
  U32 const bitMask = sizeof(bitD->bitContainer)*8 - 1;
@@ -955,11 +938,6 @@ MEM_STATIC void BITv06_skipBits(BITv06_DStream_t* bitD, U32 nbBits)
955
938
  bitD->bitsConsumed += nbBits;
956
939
  }
957
940
 
958
- /*! BITv06_readBits() :
959
- * Read (consume) next n bits from local register and update.
960
- * Pay attention to not read more than nbBits contained into local register.
961
- * @return : extracted value.
962
- */
963
941
  MEM_STATIC size_t BITv06_readBits(BITv06_DStream_t* bitD, U32 nbBits)
964
942
  {
965
943
  size_t const value = BITv06_lookBits(bitD, nbBits);
@@ -976,11 +954,6 @@ MEM_STATIC size_t BITv06_readBitsFast(BITv06_DStream_t* bitD, U32 nbBits)
976
954
  return value;
977
955
  }
978
956
 
979
- /*! BITv06_reloadDStream() :
980
- * Refill `BITv06_DStream_t` from src buffer previously defined (see BITv06_initDStream() ).
981
- * This function is safe, it guarantees it will not read beyond src buffer.
982
- * @return : status of `BITv06_DStream_t` internal register.
983
- if status == unfinished, internal register is filled with >= (sizeof(bitD->bitContainer)*8 - 7) bits */
984
957
  MEM_STATIC BITv06_DStream_status BITv06_reloadDStream(BITv06_DStream_t* bitD)
985
958
  {
986
959
  if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should never happen */
@@ -1103,55 +1076,6 @@ static void FSEv06_initDState(FSEv06_DState_t* DStatePtr, BITv06_DStream_t*
1103
1076
 
1104
1077
  static unsigned char FSEv06_decodeSymbol(FSEv06_DState_t* DStatePtr, BITv06_DStream_t* bitD);
1105
1078
 
1106
- /*!
1107
- Let's now decompose FSEv06_decompress_usingDTable() into its unitary components.
1108
- You will decode FSE-encoded symbols from the bitStream,
1109
- and also any other bitFields you put in, **in reverse order**.
1110
-
1111
- You will need a few variables to track your bitStream. They are :
1112
-
1113
- BITv06_DStream_t DStream; // Stream context
1114
- FSEv06_DState_t DState; // State context. Multiple ones are possible
1115
- FSEv06_DTable* DTablePtr; // Decoding table, provided by FSEv06_buildDTable()
1116
-
1117
- The first thing to do is to init the bitStream.
1118
- errorCode = BITv06_initDStream(&DStream, srcBuffer, srcSize);
1119
-
1120
- You should then retrieve your initial state(s)
1121
- (in reverse flushing order if you have several ones) :
1122
- errorCode = FSEv06_initDState(&DState, &DStream, DTablePtr);
1123
-
1124
- You can then decode your data, symbol after symbol.
1125
- For information the maximum number of bits read by FSEv06_decodeSymbol() is 'tableLog'.
1126
- Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out).
1127
- unsigned char symbol = FSEv06_decodeSymbol(&DState, &DStream);
1128
-
1129
- You can retrieve any bitfield you eventually stored into the bitStream (in reverse order)
1130
- Note : maximum allowed nbBits is 25, for 32-bits compatibility
1131
- size_t bitField = BITv06_readBits(&DStream, nbBits);
1132
-
1133
- All above operations only read from local register (which size depends on size_t).
1134
- Refueling the register from memory is manually performed by the reload method.
1135
- endSignal = FSEv06_reloadDStream(&DStream);
1136
-
1137
- BITv06_reloadDStream() result tells if there is still some more data to read from DStream.
1138
- BITv06_DStream_unfinished : there is still some data left into the DStream.
1139
- BITv06_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled.
1140
- BITv06_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed.
1141
- BITv06_DStream_tooFar : Dstream went too far. Decompression result is corrupted.
1142
-
1143
- When reaching end of buffer (BITv06_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop,
1144
- to properly detect the exact end of stream.
1145
- After each decoded symbol, check if DStream is fully consumed using this simple test :
1146
- BITv06_reloadDStream(&DStream) >= BITv06_DStream_completed
1147
-
1148
- When it's done, verify decompression is fully completed, by checking both DStream and the relevant states.
1149
- Checking if DStream has reached its end is performed by :
1150
- BITv06_endOfDStream(&DStream);
1151
- Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible.
1152
- FSEv06_endOfDState(&DState);
1153
- */
1154
-
1155
1079
 
1156
1080
  /* *****************************************
1157
1081
  * FSE unsafe API
@@ -511,16 +511,6 @@ MEM_STATIC BITv07_DStream_status BITv07_reloadDStream(BITv07_DStream_t* bitD);
511
511
  MEM_STATIC unsigned BITv07_endOfDStream(const BITv07_DStream_t* bitD);
512
512
 
513
513
 
514
- /* Start by invoking BITv07_initDStream().
515
- * A chunk of the bitStream is then stored into a local register.
516
- * Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t).
517
- * You can then retrieve bitFields stored into the local register, **in reverse order**.
518
- * Local register is explicitly reloaded from memory by the BITv07_reloadDStream() method.
519
- * A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BITv07_DStream_unfinished.
520
- * Otherwise, it can be less than that, so proceed accordingly.
521
- * Checking if DStream has reached its end can be performed with BITv07_endOfDStream().
522
- */
523
-
524
514
 
525
515
  /*-****************************************
526
516
  * unsafe API
@@ -533,7 +523,7 @@ MEM_STATIC size_t BITv07_readBitsFast(BITv07_DStream_t* bitD, unsigned nbBits);
533
523
  /*-**************************************************************
534
524
  * Internal functions
535
525
  ****************************************************************/
536
- MEM_STATIC unsigned BITv07_highbit32 (register U32 val)
526
+ MEM_STATIC unsigned BITv07_highbit32 (U32 val)
537
527
  {
538
528
  # if defined(_MSC_VER) /* Visual */
539
529
  unsigned long r=0;
@@ -599,13 +589,6 @@ MEM_STATIC size_t BITv07_initDStream(BITv07_DStream_t* bitD, const void* srcBuff
599
589
  }
600
590
 
601
591
 
602
- /*! BITv07_lookBits() :
603
- * Provides next n bits from local register.
604
- * local register is not modified.
605
- * On 32-bits, maxNbBits==24.
606
- * On 64-bits, maxNbBits==56.
607
- * @return : value extracted
608
- */
609
592
  MEM_STATIC size_t BITv07_lookBits(const BITv07_DStream_t* bitD, U32 nbBits)
610
593
  {
611
594
  U32 const bitMask = sizeof(bitD->bitContainer)*8 - 1;
@@ -625,11 +608,6 @@ MEM_STATIC void BITv07_skipBits(BITv07_DStream_t* bitD, U32 nbBits)
625
608
  bitD->bitsConsumed += nbBits;
626
609
  }
627
610
 
628
- /*! BITv07_readBits() :
629
- * Read (consume) next n bits from local register and update.
630
- * Pay attention to not read more than nbBits contained into local register.
631
- * @return : extracted value.
632
- */
633
611
  MEM_STATIC size_t BITv07_readBits(BITv07_DStream_t* bitD, U32 nbBits)
634
612
  {
635
613
  size_t const value = BITv07_lookBits(bitD, nbBits);
@@ -646,11 +624,6 @@ MEM_STATIC size_t BITv07_readBitsFast(BITv07_DStream_t* bitD, U32 nbBits)
646
624
  return value;
647
625
  }
648
626
 
649
- /*! BITv07_reloadDStream() :
650
- * Refill `BITv07_DStream_t` from src buffer previously defined (see BITv07_initDStream() ).
651
- * This function is safe, it guarantees it will not read beyond src buffer.
652
- * @return : status of `BITv07_DStream_t` internal register.
653
- if status == unfinished, internal register is filled with >= (sizeof(bitD->bitContainer)*8 - 7) bits */
654
627
  MEM_STATIC BITv07_DStream_status BITv07_reloadDStream(BITv07_DStream_t* bitD)
655
628
  {
656
629
  if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* should not happen => corruption detected */
@@ -874,55 +847,6 @@ static void FSEv07_initDState(FSEv07_DState_t* DStatePtr, BITv07_DStream_t*
874
847
  static unsigned char FSEv07_decodeSymbol(FSEv07_DState_t* DStatePtr, BITv07_DStream_t* bitD);
875
848
 
876
849
 
877
- /**<
878
- Let's now decompose FSEv07_decompress_usingDTable() into its unitary components.
879
- You will decode FSE-encoded symbols from the bitStream,
880
- and also any other bitFields you put in, **in reverse order**.
881
-
882
- You will need a few variables to track your bitStream. They are :
883
-
884
- BITv07_DStream_t DStream; // Stream context
885
- FSEv07_DState_t DState; // State context. Multiple ones are possible
886
- FSEv07_DTable* DTablePtr; // Decoding table, provided by FSEv07_buildDTable()
887
-
888
- The first thing to do is to init the bitStream.
889
- errorCode = BITv07_initDStream(&DStream, srcBuffer, srcSize);
890
-
891
- You should then retrieve your initial state(s)
892
- (in reverse flushing order if you have several ones) :
893
- errorCode = FSEv07_initDState(&DState, &DStream, DTablePtr);
894
-
895
- You can then decode your data, symbol after symbol.
896
- For information the maximum number of bits read by FSEv07_decodeSymbol() is 'tableLog'.
897
- Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out).
898
- unsigned char symbol = FSEv07_decodeSymbol(&DState, &DStream);
899
-
900
- You can retrieve any bitfield you eventually stored into the bitStream (in reverse order)
901
- Note : maximum allowed nbBits is 25, for 32-bits compatibility
902
- size_t bitField = BITv07_readBits(&DStream, nbBits);
903
-
904
- All above operations only read from local register (which size depends on size_t).
905
- Refueling the register from memory is manually performed by the reload method.
906
- endSignal = FSEv07_reloadDStream(&DStream);
907
-
908
- BITv07_reloadDStream() result tells if there is still some more data to read from DStream.
909
- BITv07_DStream_unfinished : there is still some data left into the DStream.
910
- BITv07_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled.
911
- BITv07_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed.
912
- BITv07_DStream_tooFar : Dstream went too far. Decompression result is corrupted.
913
-
914
- When reaching end of buffer (BITv07_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop,
915
- to properly detect the exact end of stream.
916
- After each decoded symbol, check if DStream is fully consumed using this simple test :
917
- BITv07_reloadDStream(&DStream) >= BITv07_DStream_completed
918
-
919
- When it's done, verify decompression is fully completed, by checking both DStream and the relevant states.
920
- Checking if DStream has reached its end is performed by :
921
- BITv07_endOfDStream(&DStream);
922
- Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible.
923
- FSEv07_endOfDState(&DState);
924
- */
925
-
926
850
 
927
851
  /* *****************************************
928
852
  * FSE unsafe API
@@ -59,7 +59,7 @@ extern "C" {
59
59
  /*------ Version ------*/
60
60
  #define ZSTD_VERSION_MAJOR 1
61
61
  #define ZSTD_VERSION_MINOR 3
62
- #define ZSTD_VERSION_RELEASE 2
62
+ #define ZSTD_VERSION_RELEASE 3
63
63
 
64
64
  #define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
65
65
  ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< useful to check dll version */
@@ -131,7 +131,7 @@ ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t
131
131
 
132
132
 
133
133
  /*====== Helper functions ======*/
134
- #define ZSTD_COMPRESSBOUND(srcSize) ((srcSize) + ((srcSize)>>8) + (((srcSize) < 128 KB) ? ((128 KB - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */
134
+ #define ZSTD_COMPRESSBOUND(srcSize) ((srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */
135
135
  ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case scenario */
136
136
  ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
137
137
  ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readable string from an error code */
@@ -432,12 +432,12 @@ typedef struct {
432
432
 
433
433
  typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
434
434
 
435
- /*= Custom memory allocation functions */
435
+ /*--- Custom memory allocation functions ---*/
436
436
  typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
437
437
  typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
438
438
  typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
439
439
  /* use this constant to defer to stdlib's functions */
440
- static const ZSTD_customMem ZSTD_defaultCMem = { NULL, NULL, NULL };
440
+ static ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL };
441
441
 
442
442
 
443
443
  /***************************************
@@ -446,7 +446,7 @@ static const ZSTD_customMem ZSTD_defaultCMem = { NULL, NULL, NULL };
446
446
 
447
447
  /*! ZSTD_findFrameCompressedSize() :
448
448
  * `src` should point to the start of a ZSTD encoded frame or skippable frame
449
- * `srcSize` must be at least as large as the frame
449
+ * `srcSize` must be >= first frame size
450
450
  * @return : the compressed size of the first frame starting at `src`,
451
451
  * suitable to pass to `ZSTD_decompress` or similar,
452
452
  * or an error code if input is invalid */
@@ -557,7 +557,8 @@ ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
557
557
  * It must outlive context usage.
558
558
  * workspaceSize: Use ZSTD_estimateCCtxSize() or ZSTD_estimateCStreamSize()
559
559
  * to determine how large workspace must be to support scenario.
560
- * @return : pointer to ZSTD_CCtx*, or NULL if error (size too small)
560
+ * @return : pointer to ZSTD_CCtx* (same address as workspace, but different type),
561
+ * or NULL if error (typically size too small)
561
562
  * Note : zstd will never resize nor malloc() when using a static cctx.
562
563
  * If it needs more memory than available, it will simply error out.
563
564
  * Note 2 : there is no corresponding "free" function.
@@ -587,7 +588,7 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictS
587
588
  ZSTD_compressionParameters cParams,
588
589
  ZSTD_customMem customMem);
589
590
 
590
- /*! ZSTD_initStaticCDict_advanced() :
591
+ /*! ZSTD_initStaticCDict() :
591
592
  * Generate a digested dictionary in provided memory area.
592
593
  * workspace: The memory area to emplace the dictionary into.
593
594
  * Provided pointer must 8-bytes aligned.
@@ -596,7 +597,8 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictS
596
597
  * to determine how large workspace must be.
597
598
  * cParams : use ZSTD_getCParams() to transform a compression level
598
599
  * into its relevants cParams.
599
- * @return : pointer to ZSTD_CDict*, or NULL if error (size too small)
600
+ * @return : pointer to ZSTD_CDict* (same address as workspace, but different type),
601
+ * or NULL if error (typically, size too small).
600
602
  * Note : there is no corresponding "free" function.
601
603
  * Since workspace was allocated externally, it must be freed externally.
602
604
  */
@@ -613,7 +615,7 @@ ZSTDLIB_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, uns
613
615
 
614
616
  /*! ZSTD_getParams() :
615
617
  * same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`.
616
- * All fields of `ZSTD_frameParameters` are set to default (0) */
618
+ * All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 */
617
619
  ZSTDLIB_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
618
620
 
619
621
  /*! ZSTD_checkCParams() :
@@ -660,7 +662,8 @@ ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem);
660
662
  * It must outlive context usage.
661
663
  * workspaceSize: Use ZSTD_estimateDCtxSize() or ZSTD_estimateDStreamSize()
662
664
  * to determine how large workspace must be to support scenario.
663
- * @return : pointer to ZSTD_DCtx*, or NULL if error (size too small)
665
+ * @return : pointer to ZSTD_DCtx* (same address as workspace, but different type),
666
+ * or NULL if error (typically size too small)
664
667
  * Note : zstd will never resize nor malloc() when using a static dctx.
665
668
  * If it needs more memory than available, it will simply error out.
666
669
  * Note 2 : static dctx is incompatible with legacy support
@@ -731,20 +734,22 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
731
734
  /*===== Advanced Streaming compression functions =====*/
732
735
  ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
733
736
  ZSTDLIB_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticCCtx() */
734
- ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct, a size of 0 means unknown. for a frame size of 0 use initCStream_advanced */
737
+ ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct. If it is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs, "0" also disables frame content size field. It may be enabled in the future. */
735
738
  ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); /**< creates of an internal CDict (incompatible with static CCtx), except if dict == NULL or dictSize < 8, in which case no dict is used. Note: dict is loaded with ZSTD_dm_auto (treated as a full zstd dictionary if it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy.*/
736
739
  ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize,
737
- ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be 0 (meaning unknown). note: if the contentSizeFlag is set, pledgedSrcSize == 0 means the source size is actually 0. dict is loaded with ZSTD_dm_auto and ZSTD_dlm_byCopy. */
740
+ ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct. If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. dict is loaded with ZSTD_dm_auto and ZSTD_dlm_byCopy. */
738
741
  ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); /**< note : cdict will just be referenced, and must outlive compression session */
739
- ZSTDLIB_API size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, ZSTD_frameParameters fParams, unsigned long long pledgedSrcSize); /**< same as ZSTD_initCStream_usingCDict(), with control over frame parameters */
742
+ ZSTDLIB_API size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, ZSTD_frameParameters fParams, unsigned long long pledgedSrcSize); /**< same as ZSTD_initCStream_usingCDict(), with control over frame parameters. pledgedSrcSize must be correct. If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. */
740
743
 
741
744
  /*! ZSTD_resetCStream() :
742
745
  * start a new compression job, using same parameters from previous job.
743
746
  * This is typically useful to skip dictionary loading stage, since it will re-use it in-place..
744
747
  * Note that zcs must be init at least once before using ZSTD_resetCStream().
745
- * pledgedSrcSize==0 means "srcSize unknown".
748
+ * If pledgedSrcSize is not known at reset time, use macro ZSTD_CONTENTSIZE_UNKNOWN.
746
749
  * If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end.
747
- * @return : 0, or an error code (which can be tested using ZSTD_isError()) */
750
+ * For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs,
751
+ * but it may change to mean "empty" in some future version, so prefer using macro ZSTD_CONTENTSIZE_UNKNOWN.
752
+ * @return : 0, or an error code (which can be tested using ZSTD_isError()) */
748
753
  ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
749
754
 
750
755
 
@@ -800,10 +805,10 @@ ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompress
800
805
  /*===== Buffer-less streaming compression functions =====*/
801
806
  ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
802
807
  ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
803
- ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize is optional and can be 0 (meaning unknown). note: if the contentSizeFlag is set, pledgedSrcSize == 0 means the source size is actually 0 */
808
+ ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */
804
809
  ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
805
- ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize); /* compression parameters are already set within cdict. pledgedSrcSize=0 means null-size */
806
- ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize can be 0, indicating unknown size. if it is non-zero, it must be accurate. for 0 size frames, use compressBegin_advanced */
810
+ ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize); /* compression parameters are already set within cdict. pledgedSrcSize must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */
811
+ ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */
807
812
 
808
813
  ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
809
814
  ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
@@ -1000,18 +1005,19 @@ typedef enum {
1000
1005
  * Special: value 0 means "do not change strategy". */
1001
1006
 
1002
1007
  /* frame parameters */
1003
- ZSTD_p_contentSizeFlag=200, /* Content size is written into frame header _whenever known_ (default:1)
1004
- * note that content size must be known at the beginning,
1005
- * it is sent using ZSTD_CCtx_setPledgedSrcSize() */
1008
+ ZSTD_p_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1)
1009
+ * Content size must be known at the beginning of compression,
1010
+ * it is provided using ZSTD_CCtx_setPledgedSrcSize() */
1006
1011
  ZSTD_p_checksumFlag, /* A 32-bits checksum of content is written at end of frame (default:0) */
1007
- ZSTD_p_dictIDFlag, /* When applicable, dictID of dictionary is provided in frame header (default:1) */
1012
+ ZSTD_p_dictIDFlag, /* When applicable, dictionary's ID is written into frame header (default:1) */
1008
1013
 
1009
1014
  /* multi-threading parameters */
1010
1015
  ZSTD_p_nbThreads=400, /* Select how many threads a compression job can spawn (default:1)
1011
1016
  * More threads improve speed, but also increase memory usage.
1012
1017
  * Can only receive a value > 1 if ZSTD_MULTITHREAD is enabled.
1013
1018
  * Special: value 0 means "do not change nbThreads" */
1014
- ZSTD_p_jobSize, /* Size of a compression job. Each compression job is completed in parallel.
1019
+ ZSTD_p_jobSize, /* Size of a compression job. This value is only enforced in streaming (non-blocking) mode.
1020
+ * Each compression job is completed in parallel, so indirectly controls the nb of active threads.
1015
1021
  * 0 means default, which is dynamically determined based on compression parameters.
1016
1022
  * Job size must be a minimum of overlapSize, or 1 KB, whichever is largest
1017
1023
  * The minimum size is automatically and transparently enforced */
@@ -1057,7 +1063,8 @@ typedef enum {
1057
1063
  /*! ZSTD_CCtx_setParameter() :
1058
1064
  * Set one compression parameter, selected by enum ZSTD_cParameter.
1059
1065
  * Note : when `value` is an enum, cast it to unsigned for proper type checking.
1060
- * @result : 0, or an error code (which can be tested with ZSTD_isError()). */
1066
+ * @result : informational value (typically, the one being set, possibly corrected),
1067
+ * or an error code (which can be tested with ZSTD_isError()). */
1061
1068
  ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value);
1062
1069
 
1063
1070
  /*! ZSTD_CCtx_setPledgedSrcSize() :
@@ -1066,7 +1073,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param
1066
1073
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
1067
1074
  * Note 1 : 0 means zero, empty.
1068
1075
  * In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN.
1069
- * Note that ZSTD_CONTENTSIZE_UNKNOWN is default value for new compression jobs.
1076
+ * ZSTD_CONTENTSIZE_UNKNOWN is default value for any new compression job.
1070
1077
  * Note 2 : If all data is provided and consumed in a single round,
1071
1078
  * this value is overriden by srcSize instead. */
1072
1079
  ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize);
@@ -1138,13 +1145,19 @@ typedef enum {
1138
1145
  * - Compression parameters cannot be changed once compression is started.
1139
1146
  * - outpot->pos must be <= dstCapacity, input->pos must be <= srcSize
1140
1147
  * - outpot->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.
1141
- * - @return provides the minimum amount of data still to flush from internal buffers
1148
+ * - In single-thread mode (default), function is blocking : it completed its job before returning to caller.
1149
+ * - In multi-thread mode, function is non-blocking : it just acquires a copy of input, and distribute job to internal worker threads,
1150
+ * and then immediately returns, just indicating that there is some data remaining to be flushed.
1151
+ * The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.
1152
+ * - Exception : in multi-threading mode, if the first call requests a ZSTD_e_end directive, it is blocking : it will complete compression before giving back control to caller.
1153
+ * - @return provides the minimum amount of data remaining to be flushed from internal buffers
1142
1154
  * or an error code, which can be tested using ZSTD_isError().
1143
- * if @return != 0, flush is not fully completed, there is some data left within internal buffers.
1144
- * - after a ZSTD_e_end directive, if internal buffer is not fully flushed,
1155
+ * if @return != 0, flush is not fully completed, there is still some data left within internal buffers.
1156
+ * This is useful to determine if a ZSTD_e_flush or ZSTD_e_end directive is completed.
1157
+ * - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0),
1145
1158
  * only ZSTD_e_end or ZSTD_e_flush operations are allowed.
1146
- * It is necessary to fully flush internal buffers
1147
- * before starting a new compression job, or changing compression parameters.
1159
+ * Before starting a new compression job, or changing compression parameters,
1160
+ * it is required to fully flush internal buffers.
1148
1161
  */
1149
1162
  ZSTDLIB_API size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
1150
1163
  ZSTD_outBuffer* output,
@@ -1,3 +1,3 @@
1
1
  module Zstd
2
- VERSION = "1.3.2.0"
2
+ VERSION = "1.3.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zstd-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2.0
4
+ version: 1.3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SpringMT
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-18 00:00:00.000000000 Z
11
+ date: 2018-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,7 +112,7 @@ files:
112
112
  - ext/zstdruby/libzstd/compress/fse_compress.c
113
113
  - ext/zstdruby/libzstd/compress/huf_compress.c
114
114
  - ext/zstdruby/libzstd/compress/zstd_compress.c
115
- - ext/zstdruby/libzstd/compress/zstd_compress.h
115
+ - ext/zstdruby/libzstd/compress/zstd_compress_internal.h
116
116
  - ext/zstdruby/libzstd/compress/zstd_double_fast.c
117
117
  - ext/zstdruby/libzstd/compress/zstd_double_fast.h
118
118
  - ext/zstdruby/libzstd/compress/zstd_fast.c
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.6.11
187
+ rubygems_version: 2.6.13
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)