Merge into master from pull request #242:
loci: lazily zero wire buffer (https://github.com/floodlight/loxigen/pull/242)
diff --git a/c_gen/c_match.py b/c_gen/c_match.py
index 109778b..3aad03e 100644
--- a/c_gen/c_match.py
+++ b/c_gen/c_match.py
@@ -873,7 +873,8 @@
of_match_v%(version)s_delete(wire_match);
return rv;
}
- octets->bytes = OF_MATCH_BYTES(wire_match->length);
+ of_wire_buffer_grow(wire_match->wbuf, OF_MATCH_BYTES(wire_match->length));
+ octets->bytes = wire_match->wbuf->current_bytes;
of_object_wire_buffer_steal((of_object_t *)wire_match,
&octets->data);
of_match_v%(version)s_delete(wire_match);
diff --git a/c_gen/templates/of_wire_buf.h b/c_gen/templates/of_wire_buf.h
index 2194321..dfec5c3 100644
--- a/c_gen/templates/of_wire_buf.h
+++ b/c_gen/templates/of_wire_buf.h
@@ -150,7 +150,6 @@
FREE(wbuf);
return NULL;
}
- MEMSET(wbuf->buf, 0, a_bytes);
wbuf->current_bytes = 0;
wbuf->alloc_bytes = a_bytes;
@@ -221,6 +220,7 @@
LOCI_ASSERT(wbuf != NULL);
LOCI_ASSERT(wbuf->alloc_bytes >= bytes);
if (bytes > wbuf->current_bytes) {
+ MEMSET(wbuf->buf + wbuf->current_bytes, 0, bytes - wbuf->current_bytes);
wbuf->current_bytes = bytes;
}
}