mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-02-07 12:30:53 +00:00
Use variable-length arrays instead of alloca.
This commit is contained in:
parent
c6abd58340
commit
343b2376c0
@ -32,8 +32,8 @@
|
|||||||
* A binary search index for attributes that are constrained to be
|
* A binary search index for attributes that are constrained to be
|
||||||
* monotonically increasing, which is a rather common pattern for
|
* monotonically increasing, which is a rather common pattern for
|
||||||
* time series or keys. Since this index has no storage overhead,
|
* time series or keys. Since this index has no storage overhead,
|
||||||
* it does not wear out the flash memory nor does it occupy scarce
|
* it does not wear out the flash memory nor does it occupy any
|
||||||
* scarce space. Furthermore, unlike B+-trees, it has a O(1) memory
|
* space. Furthermore, unlike B+-trees, it has a O(1) memory
|
||||||
* footprint in relation to the number of data items.
|
* footprint in relation to the number of data items.
|
||||||
* \author
|
* \author
|
||||||
* Nicolas Tsiftes <nvt@sics.se>
|
* Nicolas Tsiftes <nvt@sics.se>
|
||||||
@ -85,14 +85,9 @@ index_api_t index_inline = {
|
|||||||
static attribute_value_t *
|
static attribute_value_t *
|
||||||
get_value(tuple_id_t *index, relation_t *rel, attribute_t *attr)
|
get_value(tuple_id_t *index, relation_t *rel, attribute_t *attr)
|
||||||
{
|
{
|
||||||
unsigned char *row;
|
unsigned char row[rel->row_length];
|
||||||
static attribute_value_t value;
|
static attribute_value_t value;
|
||||||
|
|
||||||
row = alloca(rel->row_length);
|
|
||||||
if(row == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(DB_ERROR(storage_get_row(rel, index, row))) {
|
if(DB_ERROR(storage_get_row(rel, index, row))) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -142,7 +137,8 @@ binary_search(index_iterator_t *index_iterator,
|
|||||||
} else {
|
} else {
|
||||||
max = center - 1;
|
max = center - 1;
|
||||||
}
|
}
|
||||||
} while(min <= max && db_value_to_long(target_value) != db_value_to_long(cmp_value));
|
} while(min <= max &&
|
||||||
|
db_value_to_long(target_value) != db_value_to_long(cmp_value));
|
||||||
|
|
||||||
if(exact_match &&
|
if(exact_match &&
|
||||||
db_value_to_long(target_value) != db_value_to_long(cmp_value)) {
|
db_value_to_long(target_value) != db_value_to_long(cmp_value)) {
|
||||||
|
@ -475,19 +475,17 @@ relation_remove(char *name, int remove_tuples)
|
|||||||
db_result_t
|
db_result_t
|
||||||
relation_insert(relation_t *rel, attribute_value_t *values)
|
relation_insert(relation_t *rel, attribute_value_t *values)
|
||||||
{
|
{
|
||||||
size_t size;
|
|
||||||
attribute_t *attr;
|
attribute_t *attr;
|
||||||
storage_row_t record;
|
unsigned char record[rel->row_length];
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
attribute_value_t *value;
|
attribute_value_t *value;
|
||||||
db_result_t result;
|
db_result_t result;
|
||||||
|
|
||||||
value = values;
|
value = values;
|
||||||
|
|
||||||
size = rel->row_length;
|
PRINTF("DB: Relation %s has a record size of %u bytes\n",
|
||||||
PRINTF("DB: Relation %s has a record size of %d bytes\n",
|
rel->name, (unsigned)rel->row_length);
|
||||||
rel->name, (int)size);
|
ptr = record;
|
||||||
ptr = record = alloca(size);
|
|
||||||
|
|
||||||
PRINTF("DB: Insert (");
|
PRINTF("DB: Insert (");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user