Skip to content

Commit

Permalink
Create correctly sized MIO for 0 size
Browse files Browse the repository at this point in the history
  • Loading branch information
techee committed Dec 15, 2018
1 parent 56e09b9 commit e4a8bf3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions ctags/main/mio.c
Expand Up @@ -361,20 +361,20 @@ MIO *mio_new_memory (unsigned char *data,
* @size: the length of the data copied from @base to new mio
*
* Creates a new #MIO object by copying data from existing #MIO (@base).
* The range for copying are given with @start and @size.
* The range for copying is given with @start and @size.
* Copying data at the range from @start to the end of @base is
* done if 0 is given as @size.
* done if -1 is given as @size.
*
* If @size(!= 0) is larger than the length from @start to the end of
* @base, %NULL is return.
* If @size is larger than the length from @start to the end of
* @base, %NULL is returned.
*
* The function doesn't move the file position of @base.
*
* Free-function: mio_free()
*
*/

MIO *mio_new_mio (MIO *base, long start, size_t size)
MIO *mio_new_mio (MIO *base, long start, long size)
{
unsigned char *data;
long original_pos;
Expand All @@ -383,7 +383,7 @@ MIO *mio_new_mio (MIO *base, long start, size_t size)

original_pos = mio_tell (base);

if (size == 0)
if (size == -1)
{
long end;

Expand Down
2 changes: 1 addition & 1 deletion ctags/main/mio.h
Expand Up @@ -123,7 +123,7 @@ MIO *mio_new_memory (unsigned char *data,
MIOReallocFunc realloc_func,
MIODestroyNotify free_func);

MIO *mio_new_mio (MIO *base, long start, size_t size);
MIO *mio_new_mio (MIO *base, long start, long size);
MIO *mio_ref (MIO *mio);

int mio_free (MIO *mio);
Expand Down
2 changes: 1 addition & 1 deletion ctags/main/parse.c
Expand Up @@ -736,7 +736,7 @@ struct getLangCtx {
(mio_memory_get_data((_glc_)->input, NULL) == NULL)) \
{ \
MIO *tmp_ = (_glc_)->input; \
(_glc_)->input = mio_new_mio (tmp_, 0, 0); \
(_glc_)->input = mio_new_mio (tmp_, 0, -1); \
mio_free (tmp_); \
if (!(_glc_)->input) { \
(_glc_)->err = true; \
Expand Down

0 comments on commit e4a8bf3

Please sign in to comment.