Пример #1
0
static int add_codes_with_length(TreeBuildData *build,
                                 uint8_t *code_lengths,
                                 unsigned int num_code_lengths,
                                 unsigned int code_len)
{
	unsigned int i;
	unsigned int node;
	int codes_remaining;

	codes_remaining = 0;

	for (i = 0; i < num_code_lengths; ++i) {

		// Does this code belong at this depth in the tree?

		if (code_lengths[i] == code_len) {
			node = read_next_entry(build);

			build->tree[node] = (TreeElement) i | TREE_NODE_LEAF;
		}

		// More work to be done after this pass?

		else if (code_lengths[i] > code_len) {
			codes_remaining = 1;
		}
	}

	return codes_remaining;
}
Пример #2
0
static void read_file(FILE *in, unsigned char *attributes)
{
	struct entry entry[1];
	while(read_next_entry(in, entry) == 0) {
		store_attributes(entry, attributes);
	}
}
Пример #3
0
bool
compressed_file_reader_t::init()
{
    at_eof = false;
    if (file == NULL)
        return false;
    trace_entry_t *first_entry = read_next_entry();
    if (first_entry == NULL)
        return false;
    if (first_entry->type != TRACE_TYPE_HEADER ||
        first_entry->addr != TRACE_ENTRY_VERSION) {
        ERRMSG("missing header or version mismatch\n");
        return false;
    }
    ++*this;
    return true;
}