MEDIUM: chunks: make the chunk struct's fields match the buffer struct
Chunks are only a subset of a buffer (a non-wrapping version with no head
offset). Despite this we still carry a lot of duplicated code between
buffers and chunks. Replacing chunks with buffers would significantly
reduce the maintenance efforts. This first patch renames the chunk's
fields to match the name and types used by struct buffers, with the goal
of isolating the code changes from the declaration changes.
Most of the changes were made with spatch using this coccinelle script :
@rule_d1@
typedef chunk;
struct chunk chunk;
@@
- chunk.str
+ chunk.area
@rule_d2@
typedef chunk;
struct chunk chunk;
@@
- chunk.len
+ chunk.data
@rule_i1@
typedef chunk;
struct chunk *chunk;
@@
- chunk->str
+ chunk->area
@rule_i2@
typedef chunk;
struct chunk *chunk;
@@
- chunk->len
+ chunk->data
Some minor updates to 3 http functions had to be performed to take size_t
ints instead of ints in order to match the unsigned length here.
diff --git a/src/wurfl.c b/src/wurfl.c
index 591fbdb..9d2dfa6 100644
--- a/src/wurfl.c
+++ b/src/wurfl.c
@@ -576,8 +576,8 @@
}
wurfl_device_destroy(dHandle);
- smp->data.u.str.str = temp->str;
- smp->data.u.str.len = temp->len;
+ smp->data.u.str.area = temp->area;
+ smp->data.u.str.data = temp->data;
return 1;
}
@@ -602,9 +602,9 @@
temp = get_trash_chunk();
chunk_reset(temp);
- while (args[i].data.str.str) {
+ while (args[i].data.str.area) {
chunk_appendf(temp, "%c", global_wurfl.information_list_separator);
- node = ebst_lookup(&global_wurfl.btree, args[i].data.str.str);
+ node = ebst_lookup(&global_wurfl.btree, args[i].data.str.area);
wn = container_of(node, wurfl_data_t, nd);
if (wn) {
@@ -644,15 +644,16 @@
}
} else {
- ha_wurfl_log("WURFL: %s not in wurfl-information-list \n", args[i].data.str.str);
+ ha_wurfl_log("WURFL: %s not in wurfl-information-list \n",
+ args[i].data.str.area);
}
i++;
}
wurfl_device_destroy(dHandle);
- smp->data.u.str.str = temp->str;
- smp->data.u.str.len = temp->len;
+ smp->data.u.str.area = temp->area;
+ smp->data.u.str.data = temp->data;
return 1;
}