-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Unlike 'typeset -si' short int values, enum values (which are glorified unsigned short ints) were still stored directly in the nvalue union. As of this commit, they use pointers to allocated memory like other values. Notable changes: src/cmd/ksh93/bltins/enum.c: - Assign NV_INT16P (which uses value pointers) instead of NV_INT16 attribute bits to enum variables when assigning or creating them. src/cmd/ksh93/include/streval.h: - struct lval: Rename opaquely named enum-related 'ptr' and 'eflag' members to 'enum_p' and 'isenum', respectively. src/cmd/ksh93/sh/arith.c: arith(): - When comparing an enum's value using the == or != operators in an arithmetic expression, the rvalue (right-hand value) may be an enum value if the lvalue is a variable of an enum type. Update the code that handles this to no longer require the NV_NOFREE attribute on the temporary node, as short ints (including enums) now use pointers and allocated memory. - Fix a pre-existing memory leak. In the old version of that code block, while the value of the temporary node was not freeable, the discipline function entry (nvfun) did need to be freed. Make sure everything is freed properly by calling _nv_unset(). src/cmd/ksh93/sh/array.c: nv_getsub(): - Fix enum subscripts to use the current method: malloc a value and assign the subscript numeric value via the pointer instead of directly to the nvalue union. src/cmd/ksh93/tests/leaks.sh: - Add test for the leak fixed in arith.c.
- Loading branch information
Showing
6 changed files
with
41 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters