# HG changeset patch # User Paul Boddie # Date 1478004750 -3600 # Node ID 989663c465ca65fecfde6132c85949a739a2d8f4 # Parent 49376f3ab03dea1df169bc151903bde88cc1ce14 Fixed fragment allocation and adopted the appropriate data types and casting. diff -r 49376f3ab03d -r 989663c465ca templates/progops.c --- a/templates/progops.c Mon Oct 31 21:53:38 2016 +0100 +++ b/templates/progops.c Tue Nov 01 13:52:30 2016 +0100 @@ -11,9 +11,9 @@ /* Generic instantiation operations, defining common members. */ -__attr __new(const __table * table, __ref cls, int size) +__attr __new(const __table * table, __ref cls, size_t size) { - __ref obj = calloc(1, size); + __ref obj = (__ref) calloc(1, size); __attr self = {obj, obj}; __attr tmp = {0, cls}; obj->table = table; @@ -25,7 +25,8 @@ __attr __newdata(__attr args[], unsigned int number) { - __fragment *data = calloc(number, sizeof(__attr)); + /* Manually calculate the size of the fragment. */ + __fragment *data = (__fragment *) calloc(1, number * sizeof(__attr) + sizeof(unsigned int)); __attr attr = {0, .data=data}; unsigned int i, j; diff -r 49376f3ab03d -r 989663c465ca templates/progops.h --- a/templates/progops.h Mon Oct 31 21:53:38 2016 +0100 +++ b/templates/progops.h Tue Nov 01 13:52:30 2016 +0100 @@ -1,10 +1,11 @@ /* Program type definitions. */ +#include #include "types.h" /* Common operations. */ -__attr __new(const __table *table, __ref cls, int size); +__attr __new(const __table *table, __ref cls, size_t size); __attr __newdata(__attr args[], unsigned int number);