diff options
author | Guido van Rossum <guido@python.org> | 1992-07-31 15:11:01 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-07-31 15:11:01 (GMT) |
commit | e6e9fe18bb7d3be69d28b1c25015e77b2f2a908d (patch) | |
tree | f74aedaf8adb343ef7be2daf735d273d9d2eda1f /Modules | |
parent | 500982062f98b6dfdf15166bf98a78c650470386 (diff) | |
download | cpython-e6e9fe18bb7d3be69d28b1c25015e77b2f2a908d.zip cpython-e6e9fe18bb7d3be69d28b1c25015e77b2f2a908d.tar.gz cpython-e6e9fe18bb7d3be69d28b1c25015e77b2f2a908d.tar.bz2 |
Changes to make it compile under SGI -- revamped new/dealloc a bit.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/rotormodule.c | 64 |
1 files changed, 25 insertions, 39 deletions
diff --git a/Modules/rotormodule.c b/Modules/rotormodule.c index 2950a93..e40615f 100644 --- a/Modules/rotormodule.c +++ b/Modules/rotormodule.c @@ -157,49 +157,35 @@ newrotorobject(num_rotors, key) xp = NEWOBJ(rotorobject, &Rotortype); if (xp == NULL) return NULL; - set_key(xp,key); + set_key(xp, key); xp->size = 256; xp->size_mask = xp->size - 1; xp->size_mask = 0; xp->rotors = num_rotors; - - xp->e_rotor = (unsigned char *)malloc((num_rotors * (xp->size * sizeof(char)))); - if (xp->e_rotor == (unsigned char *)NULL) { - err_nomem(); - DEL(xp); - xp = (object *)NULL; - goto done; - } - xp->d_rotor = (unsigned char *)malloc((num_rotors * (xp->size * sizeof(char)))); - if (xp->d_rotor == (unsigned char *)NULL) { - err_nomem(); - free(xp->e_rotor); - DEL(xp); - xp = (object *)NULL; - goto done; - } + xp->e_rotor = NULL; + xp->d_rotor = NULL; + xp->positions = NULL; + xp->advances = NULL; + + xp->e_rotor = + (unsigned char *)malloc((num_rotors * (xp->size * sizeof(char)))); + if (xp->e_rotor == (unsigned char *)NULL) + goto fail; + xp->d_rotor = + (unsigned char *)malloc((num_rotors * (xp->size * sizeof(char)))); + if (xp->d_rotor == (unsigned char *)NULL) + goto fail; xp->positions = (unsigned char *)malloc(num_rotors * sizeof(char)); - if (xp->positions == (unsigned char *)NULL) { - err_nomem(); - free(xp->e_rotor); - free(xp->d_rotor); - DEL(xp); - xp = (object *)NULL; - goto done; - } + if (xp->positions == (unsigned char *)NULL) + goto fail; xp->advances = (unsigned char *)malloc(num_rotors * sizeof(char)); - if (xp->advances == (unsigned char *)NULL) { - err_nomem(); - free(xp->e_rotor); - free(xp->d_rotor); - free(xp->positions); - DEL(xp); - xp = (object *)NULL; - goto done; - } -done: + if (xp->advances == (unsigned char *)NULL) + goto fail; return xp; +fail: + DECREF(xp); + return (rotorobject *)err_nomem(); } /* These routines impliment the rotor itself */ @@ -594,10 +580,10 @@ static void rotor_dealloc(xp) rotorobject *xp; { - free(xp->e_rotor); - free(xp->d_rotor); - free(xp->positions); - free(xp->advances); + XDEL(xp->e_rotor); + XDEL(xp->d_rotor); + XDEL(xp->positions); + XDEL(xp->advances); DEL(xp); } |