1.1 --- a/templates/progops.c Mon Oct 31 21:53:38 2016 +0100
1.2 +++ b/templates/progops.c Tue Nov 01 13:52:30 2016 +0100
1.3 @@ -11,9 +11,9 @@
1.4
1.5 /* Generic instantiation operations, defining common members. */
1.6
1.7 -__attr __new(const __table * table, __ref cls, int size)
1.8 +__attr __new(const __table * table, __ref cls, size_t size)
1.9 {
1.10 - __ref obj = calloc(1, size);
1.11 + __ref obj = (__ref) calloc(1, size);
1.12 __attr self = {obj, obj};
1.13 __attr tmp = {0, cls};
1.14 obj->table = table;
1.15 @@ -25,7 +25,8 @@
1.16
1.17 __attr __newdata(__attr args[], unsigned int number)
1.18 {
1.19 - __fragment *data = calloc(number, sizeof(__attr));
1.20 + /* Manually calculate the size of the fragment. */
1.21 + __fragment *data = (__fragment *) calloc(1, number * sizeof(__attr) + sizeof(unsigned int));
1.22 __attr attr = {0, .data=data};
1.23 unsigned int i, j;
1.24
2.1 --- a/templates/progops.h Mon Oct 31 21:53:38 2016 +0100
2.2 +++ b/templates/progops.h Tue Nov 01 13:52:30 2016 +0100
2.3 @@ -1,10 +1,11 @@
2.4 /* Program type definitions. */
2.5
2.6 +#include <stdlib.h>
2.7 #include "types.h"
2.8
2.9 /* Common operations. */
2.10
2.11 -__attr __new(const __table *table, __ref cls, int size);
2.12 +__attr __new(const __table *table, __ref cls, size_t size);
2.13
2.14 __attr __newdata(__attr args[], unsigned int number);
2.15