-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from pauldmccarthy/bf/export
Bf/export
- Loading branch information
Showing
10 changed files
with
154 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ | |
ZranError) | ||
|
||
|
||
__version__ = '0.8.8' | ||
__version__ = '0.8.9' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
* | ||
* Author: Paul McCarthy <[email protected]> | ||
*/ | ||
|
||
#include <math.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
@@ -36,6 +37,13 @@ static int is_readonly(FILE *fd) | |
{ | ||
return (fcntl(fileno(fd), F_GETFL) & O_ACCMODE) == O_RDONLY; | ||
} | ||
|
||
|
||
static uint32_t max(uint32_t a, uint32_t b) { | ||
|
||
if (a > b) return a; | ||
else return b; | ||
} | ||
#endif | ||
|
||
#include "zran.h" | ||
|
@@ -416,7 +424,7 @@ uint32_t ZRAN_INFLATE_STOP_AT_BLOCK = 64; | |
* parameters are respectively updated to contain the total number of | ||
* compressed bytes that were read from the file, and total number of | ||
* decompressed bytes that were copied to the data buffer. | ||
* | ||
* - ZRAN_INFLATE_OK: Inflation was successful and the requested | ||
* number of bytes were copied to the provided | ||
* data buffer. | ||
|
@@ -2698,8 +2706,11 @@ int zran_import_index(zran_index_t *index, | |
* At this step, the number of points is known. Allocate space for new list | ||
* of points. This pointer should be cleaned up before exit in case of | ||
* failure. | ||
* | ||
* The index file is allowed to contain 0 points, in which case we | ||
* initialise the point list to 8 (same as in zran_init). | ||
*/ | ||
new_list = calloc(1, sizeof(zran_point_t) * npoints); | ||
new_list = calloc(1, sizeof(zran_point_t) * max(npoints, 8)); | ||
|
||
if (new_list == NULL) goto memory_error; | ||
|
||
|
@@ -2836,8 +2847,12 @@ int zran_import_index(zran_index_t *index, | |
index->list = new_list; | ||
index->npoints = npoints; | ||
|
||
/* Let's not forget to update the size as well. */ | ||
index->size = npoints; | ||
/* | ||
* Let's not forget to update the size as well. | ||
* If npoints is 0, the list will have been | ||
* initialised to allow space for 8 points. | ||
*/ | ||
index->size = max(npoints, 8); | ||
|
||
zran_log("zran_import_index: done\n"); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters