76 |
|
|
77 |
#define ERRS_ALLOC(Nerrs) \ |
#define ERRS_ALLOC(Nerrs) \ |
78 |
(errs_t *) xcalloc ((unsigned) (sizeof (errs_t) \ |
(errs_t *) xcalloc ((unsigned) (sizeof (errs_t) \ |
79 |
+ (Nerrs - 1) * sizeof (short)), 1) |
+ (Nerrs - 1) * sizeof (symbol_number_t)), 1) |
80 |
|
|
81 |
|
|
82 |
errs_t * |
errs_t * |
83 |
errs_new (int n) |
errs_new (int n) |
84 |
{ |
{ |
85 |
errs_t *res = ERRS_ALLOC (n); |
errs_t *res = ERRS_ALLOC (n); |
86 |
res->nerrs = n; |
res->num = n; |
87 |
return res; |
return res; |
88 |
} |
} |
89 |
|
|
91 |
errs_t * |
errs_t * |
92 |
errs_dup (errs_t *src) |
errs_dup (errs_t *src) |
93 |
{ |
{ |
94 |
errs_t *res = errs_new (src->nerrs); |
errs_t *res = errs_new (src->num); |
95 |
memcpy (res->errs, src->errs, src->nerrs * sizeof (src->errs[0])); |
memcpy (res->symbols, src->symbols, src->num * sizeof (src->symbols[0])); |
96 |
return res; |
return res; |
97 |
} |
} |
98 |
|
|
110 |
|
|
111 |
#define REDUCTIONS_ALLOC(Nreductions) \ |
#define REDUCTIONS_ALLOC(Nreductions) \ |
112 |
(reductions_t *) xcalloc ((unsigned) (sizeof (reductions_t) \ |
(reductions_t *) xcalloc ((unsigned) (sizeof (reductions_t) \ |
113 |
+ (Nreductions - 1) * sizeof (short)), 1) |
+ (Nreductions - 1) * sizeof (rule_number_t)), 1) |
114 |
|
|
115 |
static reductions_t * |
static reductions_t * |
116 |
reductions_new (int nreductions, short *reductions) |
reductions_new (int nreductions, short *reductions) |
117 |
{ |
{ |
118 |
reductions_t *res = REDUCTIONS_ALLOC (nreductions); |
reductions_t *res = REDUCTIONS_ALLOC (nreductions); |
119 |
res->nreds = nreductions; |
res->num = nreductions; |
120 |
memcpy (res->rules, reductions, nreductions * sizeof (reductions[0])); |
memcpy (res->rules, reductions, nreductions * sizeof (reductions[0])); |
121 |
return res; |
return res; |
122 |
} |
} |