try to avoid aliasing of pointers enum {} vs int

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21503 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-07-12 11:57:19 +00:00
parent 22621903bc
commit 6304d68d16
3 changed files with 19 additions and 18 deletions

View File

@@ -262,12 +262,14 @@ decode_type (const char *name, const Type *t, int optional,
}
case TInteger:
if(t->members) {
char *s;
asprintf(&s, "(int*)%s", name);
if (s == NULL)
errx (1, "out of memory");
decode_primitive ("integer", s, forwstr);
free(s);
fprintf(codefile,
"{\n"
"int enumint;\n");
decode_primitive ("integer", "&enumint", forwstr);
fprintf(codefile,
"*%s = enumint;\n"
"}\n",
name);
} else if (t->range == NULL) {
decode_primitive ("heim_integer", name, forwstr);
} else if (t->range->min == INT_MIN && t->range->max == INT_MAX) {

View File

@@ -121,12 +121,12 @@ encode_type (const char *name, const Type *t, const char *tmpstr)
break;
case TInteger:
if(t->members) {
char *s;
asprintf(&s, "(const int*)%s", name);
if(s == NULL)
errx(1, "out of memory");
encode_primitive ("integer", s);
free(s);
fprintf(codefile,
"{\n"
"int enumint = (int)*%s;\n",
name);
encode_primitive ("integer", "&enumint");
fprintf(codefile, "}\n;");
} else if (t->range == NULL) {
encode_primitive ("heim_integer", name);
} else if (t->range->min == INT_MIN && t->range->max == INT_MAX) {

View File

@@ -72,12 +72,11 @@ length_type (const char *name, const Type *t,
break;
case TInteger:
if(t->members) {
char *s;
asprintf(&s, "(const int*)%s", name);
if(s == NULL)
errx (1, "out of memory");
length_primitive ("integer", s, variable);
free(s);
fprintf(codefile,
"{\n"
"int enumint = *%s;\n", name);
length_primitive ("integer", "&enumint", variable);
fprintf(codefile, "}\n");
} else if (t->range == NULL) {
length_primitive ("heim_integer", name, variable);
} else if (t->range->min == INT_MIN && t->range->max == INT_MAX) {