Class: ZstdNative::CDict
- Inherits:
-
Object
- Object
- ZstdNative::CDict
- Defined in:
- ext/zstd_native/zstd_native.c
Instance Method Summary collapse
- #initialize(*args) ⇒ Object constructor
- #sizeof ⇒ Object
Constructor Details
#initialize(*args) ⇒ Object
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 |
# File 'ext/zstd_native/zstd_native.c', line 559
static VALUE cdict_initialize(int argc, VALUE *argv, VALUE self) {
VALUE dict, level_val;
rb_scan_args(argc, argv, "11", &dict, &level_val);
Check_Type(dict, T_STRING);
int level = NIL_P(level_val) ? ZSTD_CLEVEL_DEFAULT : NUM2INT(level_val);
const char *dict_data = RSTRING_PTR(dict);
size_t dict_size = RSTRING_LEN(dict);
ZSTD_CDict *cdict = ZSTD_createCDict(dict_data, dict_size, level);
if (!cdict) {
rb_raise(eZstdError, "Failed to create compression dictionary");
}
DATA_PTR(self) = cdict;
return self;
}
|
Instance Method Details
#sizeof ⇒ Object
582 583 584 585 586 |
# File 'ext/zstd_native/zstd_native.c', line 582
static VALUE cdict_sizeof(VALUE self) {
ZSTD_CDict *cdict;
TypedData_Get_Struct(self, ZSTD_CDict, &cdict_type, cdict);
return SIZET2NUM(ZSTD_sizeof_CDict(cdict));
}
|