AmendHub

Download:

jcs

/

subtext

/

amendments

/

9

util: Add xSetHandleSize


jcs made amendment 9 over 2 years ago
--- util.c Sat Dec 4 20:28:02 2021 +++ util.c Mon Dec 6 09:08:13 2021 @@ -263,10 +263,8 @@ unsigned long xorshift32(void) { unsigned long x = _xorshift_state; - if (x == 0) { - x = Time; - /* TODO: stir in seed stored in resource file */ - } + if (x == 0) + x = Ticks; x ^= x << 13; x ^= x >> 17; x ^= x << 5; @@ -283,6 +281,9 @@ xNewHandle(unsigned long size) { Handle h; + if (size < 1) + err(1, "Bogus xNewHandle size %lu", size); + h = NewHandle(size); if (h == NULL) err(1, "Failed to NewHandle(%lu)", size); @@ -314,6 +315,13 @@ xGetString(short id) return h; } +void +xSetHandleSize(Handle h, Size s) +{ + SetHandleSize(h, s); + if (MemError()) + err(1, "Failed to SetHandleSize to %ld", s); +} /* * Filesystem utilities --- util.h Sun Dec 5 16:22:51 2021 +++ util.h Mon Dec 6 09:08:31 2021 @@ -83,6 +83,7 @@ Handle xGetResource(ResType type, short id); StringHandle xGetString(short id); char *xGetStringAsChar(short id); long xGetStringAsLong(short id); +void xSetHandleSize(Handle h, Size s); char *askfileordirpath(void); short getpath(short vRefNum, Str255 fileName, char **ret,