Skip to content

Commit

Permalink
fix computation of memsize for node lists
Browse files Browse the repository at this point in the history
  • Loading branch information
froydnj committed Sep 18, 2023
1 parent 0f97174 commit 02aab8b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion templates/src/node.c.erb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ yp_node_memsize_node(yp_node_t *node, yp_memsize_t *memsize) {
case <%= node.type %>: {
yp_<%= node.human %>_t *cast = (yp_<%= node.human %>_t *) node;
memsize->memsize += sizeof(*cast);
<%- if node.fields.any? { |f| f.is_a?(YARP::NodeListField) } -%>
// Node lists will add in their own sizes below.
memsize->memsize -= sizeof(yp_node_list_t) * <%= node.fields.count { |f| f.is_a?(YARP::NodeListField) } %>;
<%- end -%>
<%- node.fields.each do |field| -%>
<%- case field -%>
<%- when YARP::ConstantField, YARP::OptionalConstantField, YARP::UInt32Field, YARP::FlagsField, YARP::LocationField, YARP::OptionalLocationField -%>
Expand All @@ -114,7 +118,7 @@ yp_node_memsize_node(yp_node_t *node, yp_memsize_t *memsize) {
<%- when YARP::StringField -%>
memsize->memsize += yp_string_memsize(&cast-><%= field.name %>);
<%- when YARP::NodeListField -%>
yp_node_list_memsize(&cast-><%= field.name %>, memsize);
memsize->memsize += yp_node_list_memsize(&cast-><%= field.name %>, memsize);
<%- when YARP::ConstantListField -%>
memsize->memsize += yp_constant_id_list_memsize(&cast-><%= field.name %>);
<%- else -%>
Expand Down

0 comments on commit 02aab8b

Please sign in to comment.