Commit dd1058f6 authored by Guido van Rossum's avatar Guido van Rossum

Changes to make it compile under SGI -- revamped new/dealloc a bit.

parent 07b9a7fb
...@@ -157,49 +157,35 @@ newrotorobject(num_rotors, key) ...@@ -157,49 +157,35 @@ newrotorobject(num_rotors, key)
xp = NEWOBJ(rotorobject, &Rotortype); xp = NEWOBJ(rotorobject, &Rotortype);
if (xp == NULL) if (xp == NULL)
return NULL; return NULL;
set_key(xp,key); set_key(xp, key);
xp->size = 256; xp->size = 256;
xp->size_mask = xp->size - 1; xp->size_mask = xp->size - 1;
xp->size_mask = 0; xp->size_mask = 0;
xp->rotors = num_rotors; xp->rotors = num_rotors;
xp->e_rotor = NULL;
xp->e_rotor = (unsigned char *)malloc((num_rotors * (xp->size * sizeof(char)))); xp->d_rotor = NULL;
if (xp->e_rotor == (unsigned char *)NULL) { xp->positions = NULL;
err_nomem(); xp->advances = NULL;
DEL(xp);
xp = (object *)NULL; xp->e_rotor =
goto done; (unsigned char *)malloc((num_rotors * (xp->size * sizeof(char))));
} if (xp->e_rotor == (unsigned char *)NULL)
xp->d_rotor = (unsigned char *)malloc((num_rotors * (xp->size * sizeof(char)))); goto fail;
if (xp->d_rotor == (unsigned char *)NULL) { xp->d_rotor =
err_nomem(); (unsigned char *)malloc((num_rotors * (xp->size * sizeof(char))));
free(xp->e_rotor); if (xp->d_rotor == (unsigned char *)NULL)
DEL(xp); goto fail;
xp = (object *)NULL;
goto done;
}
xp->positions = (unsigned char *)malloc(num_rotors * sizeof(char)); xp->positions = (unsigned char *)malloc(num_rotors * sizeof(char));
if (xp->positions == (unsigned char *)NULL) { if (xp->positions == (unsigned char *)NULL)
err_nomem(); goto fail;
free(xp->e_rotor);
free(xp->d_rotor);
DEL(xp);
xp = (object *)NULL;
goto done;
}
xp->advances = (unsigned char *)malloc(num_rotors * sizeof(char)); xp->advances = (unsigned char *)malloc(num_rotors * sizeof(char));
if (xp->advances == (unsigned char *)NULL) { if (xp->advances == (unsigned char *)NULL)
err_nomem(); goto fail;
free(xp->e_rotor);
free(xp->d_rotor);
free(xp->positions);
DEL(xp);
xp = (object *)NULL;
goto done;
}
done:
return xp; return xp;
fail:
DECREF(xp);
return (rotorobject *)err_nomem();
} }
/* These routines impliment the rotor itself */ /* These routines impliment the rotor itself */
...@@ -594,10 +580,10 @@ static void ...@@ -594,10 +580,10 @@ static void
rotor_dealloc(xp) rotor_dealloc(xp)
rotorobject *xp; rotorobject *xp;
{ {
free(xp->e_rotor); XDEL(xp->e_rotor);
free(xp->d_rotor); XDEL(xp->d_rotor);
free(xp->positions); XDEL(xp->positions);
free(xp->advances); XDEL(xp->advances);
DEL(xp); DEL(xp);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment