Skip to content

Commit e3663af

Browse files
author
Luke Shaw
committed
Getting ready for release 2.21.3
1 parent 7e5c240 commit e3663af

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

ANNOUNCE.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# Announcing C-Blosc2 2.21.2
1+
# Announcing C-Blosc2 2.21.3
22
A fast, compressed and persistent binary data store library for C.
33

44
## What is new?
55

6-
This is a maintenance release, with a few fixes and some optimizations.
7-
Thanks to Barak Ugav and Preeyan Parmar for their contributions.
6+
The main change is an increase in the maximum number of dimensions for
7+
b2nd arrays from 8 to 16. Otherwise, this is a maintenance release, with a
8+
few fixes and some optimizations. Thanks to Barak Ugav and Antonio Valentino
9+
for their contributions.
810

911
For more info, see the release notes in:
1012

RELEASE_NOTES.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
Release notes for C-Blosc2
22
==========================
33

4-
Changes from 2.21.2 to 2.21.3
4+
Changes from 2.21.3 to 2.21.4
55
=============================
66

77
#XXX version-specific blurb XXX#
88

9+
Changes from 2.21.2 to 2.21.3
10+
=============================
11+
12+
* Increase MAX_DIMS from 8 to 16
13+
* Fix compatibility with glibc v2.42
14+
* Bug fix in ``unidim_to_multidim``
15+
916
Changes from 2.21.1 to 2.21.2
1017
=============================
1118

blosc/schunk.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,42 @@ static bool file_exists (char *filename) {
124124
return (stat (filename, &buffer) == 0);
125125
}
126126

127+
void schunk_base_incref(blosc2_schunk *schunk)
128+
{
129+
blosc2_schunk *base;
130+
if (schunk->base != NULL) {
131+
base = schunk->base;
132+
}
133+
else {
134+
base = schunk;
135+
}
136+
base->refcount += 1;
137+
}
138+
139+
/* Decrement owner refcount and free owner when reaches zero.
140+
* Note: this frees the owner struct itself; callers must ensure they don't access owner afterwards.
141+
*/
142+
void schunk_base_decref(blosc2_schunk *schunk)
143+
{
144+
blosc2_schunk *base;
145+
if (schunk->base != NULL) {
146+
base = schunk->base;
147+
}
148+
else {
149+
base = schunk;
150+
}
151+
base->refcount -= 1;
152+
if (base->refcount <= 0) {
153+
blosc2_schunk_free(base); // this frees schunk and will free data if necessary
154+
}
155+
}
127156

128157
/* Create a new super-chunk */
129158
blosc2_schunk* blosc2_schunk_new(blosc2_storage *storage) {
130159
blosc2_schunk* schunk = calloc(1, sizeof(blosc2_schunk));
131160
schunk->version = 0; /* pre-first version */
132161
schunk->base = (blosc2_schunk*) NULL; /* not a view by default, is its own base */
162+
schunk->refcount = 1; /* one reference by default */
133163

134164
// Get the storage with proper defaults
135165
schunk->storage = get_new_storage(storage, &BLOSC2_CPARAMS_DEFAULTS, &BLOSC2_DPARAMS_DEFAULTS, &BLOSC2_IO_DEFAULTS);
@@ -494,7 +524,7 @@ int64_t blosc2_schunk_append_file(blosc2_schunk* schunk, const char* urlpath) {
494524
int blosc2_schunk_free(blosc2_schunk *schunk) {
495525
int err = 0;
496526

497-
if (schunk->data != NULL && schunk->base != NULL) {
527+
if (schunk->data != NULL && schunk->base == NULL) {
498528
// If not a view (and so base points to true array), free all chunks
499529
for (int i = 0; i < schunk->nchunks; i++) {
500530
free(schunk->data[i]);
@@ -540,7 +570,7 @@ int blosc2_schunk_free(blosc2_schunk *schunk) {
540570
free(schunk->storage);
541571
}
542572

543-
if (schunk->frame != NULL && schunk->base != NULL) {
573+
if (schunk->frame != NULL && schunk->base == NULL) {
544574
// If not a view (and so base points to true array), free all chunks
545575
frame_free((blosc2_frame_s *) schunk->frame);
546576
}

0 commit comments

Comments
 (0)