Module: wine Branch: master Commit: 701a25c4b2b208e43a059b4ff8092972ab4b3c0f URL: http://source.winehq.org/git/wine.git/?a=commit;h=701a25c4b2b208e43a059b4ff8...
Author: Rob Shearman rob@codeweavers.com Date: Mon Dec 10 13:30:23 2007 +0000
widl: Always write a freeing function for arrays in generated code.
Fix the conditions under which pfnFree is called to only include arrays that will have been allocated, instead of being pointed to the buffer.
---
tools/widl/typegen.c | 24 ++++++++++++++---------- 1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 1078ede..ae80f93 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -2755,7 +2755,7 @@ void write_remoting_arguments(FILE *file, int indent, const func_t *func, } else if (tc == RPC_FC_CARRAY) { - if (is_size_needed_for_phase(phase) && phase != PHASE_FREE) + if (is_size_needed_for_phase(phase)) { print_file(file, indent, "_StubMsg.MaxCount = (unsigned long)"); write_expr(file, type->size_is, 1); @@ -2786,16 +2786,20 @@ void write_remoting_arguments(FILE *file, int indent, const func_t *func, : "ConformantVaryingArray"); }
- if (!in_attr && phase == PHASE_FREE) - { - print_file(file, indent, "if (%s)\n", var->name); - indent++; - print_file(file, indent, "_StubMsg.pfnFree(%s);\n", var->name); - } - else if (phase != PHASE_FREE) + if (pointer_type != RPC_FC_RP) array_type = "Pointer"; + print_phase_function(file, indent, array_type, phase, var, start_offset); + if (phase == PHASE_FREE && type->declarray && pointer_type == RPC_FC_RP) { - const char *t = pointer_type == RPC_FC_RP ? array_type : "Pointer"; - print_phase_function(file, indent, t, phase, var, start_offset); + /* these are all unmarshalled by pointing into the buffer on the + * server side */ + if (type->type != RPC_FC_SMFARRAY && + type->type != RPC_FC_LGFARRAY && + type->type != RPC_FC_CARRAY) + { + print_file(file, indent, "if (%s)\n", var->name); + indent++; + print_file(file, indent, "_StubMsg.pfnFree(%s);\n", var->name); + } } } else if (!is_ptr(var->type) && is_base_type(rtype))