Alien-LibJIT
view release on metacpan or search on metacpan
libjit/jit/jit-varint.c view on Meta::CPAN
/*
* jit-varint.c - Variable length integer encoding.
*
* Copyright (C) 2011 Aleksey Demakov
*
* The libjit library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 2.1 of
* the License, or (at your option) any later version.
*
* The libjit library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the libjit library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <jit/jit.h>
#include "jit-varint.h"
/*
* Flush the current encode buffer.
*/
static int
flush_encoder(jit_varint_encoder_t *encoder)
{
jit_varint_data_t data;
/* Allocate a new jit_varint_data structure to hold the data */
data = jit_malloc(sizeof(struct jit_varint_data) + encoder->len);
if(!data)
{
return 0;
}
/* Copy the temporary debug data into the new structure */
jit_memcpy(data->data, encoder->buf, encoder->len);
/* Link the structure into the debug list */
data->next = 0;
if(encoder->last)
{
encoder->last->next = data;
}
else
{
encoder->data = data;
}
encoder->last = data;
/* Reset the temporary debug buffer */
encoder->len = 0;
return 1;
}
void
_jit_varint_init_encoder(jit_varint_encoder_t *encoder)
{
encoder->len = 0;
( run in 1.307 second using v1.01-cache-2.11-cpan-8450f2e95f3 )