summaryrefslogtreecommitdiff
path: root/librabbitmq/codegen.py
diff options
context:
space:
mode:
authorTony Garnock-Jones <tonygarnockjones@gmail.com>2010-04-20 18:20:28 +1200
committerTony Garnock-Jones <tonygarnockjones@gmail.com>2010-04-20 18:20:28 +1200
commitdb3c67727ea1dc2a6d182b5e622e94795b2b8f3b (patch)
treed8916d6adc095fd504fbe1089b4d33b65554ce49 /librabbitmq/codegen.py
parentaeeb9be974bed7af14b852e426c2a43aebea1678 (diff)
downloadrabbitmq-c-github-ask-db3c67727ea1dc2a6d182b5e622e94795b2b8f3b.tar.gz
Only allocate and check if we would ask for more than zero bytes
Diffstat (limited to 'librabbitmq/codegen.py')
-rw-r--r--librabbitmq/codegen.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/librabbitmq/codegen.py b/librabbitmq/codegen.py
index 7683783..7aea9f4 100644
--- a/librabbitmq/codegen.py
+++ b/librabbitmq/codegen.py
@@ -167,9 +167,12 @@ def genErl(spec):
def genDecodeMethodFields(m):
print " case %s: {" % (m.defName(),)
- print " %s *m = (%s *) amqp_pool_alloc(pool, sizeof(%s));" % \
- (m.structName(), m.structName(), m.structName())
- print " if (m == NULL) { return -ENOMEM; }"
+ if m.arguments:
+ print " %s *m = (%s *) amqp_pool_alloc(pool, sizeof(%s));" % \
+ (m.structName(), m.structName(), m.structName())
+ print " if (m == NULL) { return -ENOMEM; }"
+ else:
+ print " %s *m = NULL; /* no fields */" % (m.structName(),)
bitindex = None
for f in m.arguments:
if spec.resolveDomain(f.domain) == 'bit':