Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd96f139

Browse files
authored
Reduce the memory consumption of heapframe (#849)
Several local members are removed, or their size(e.g. uint32_t -> uint8_t) is reduced in heapframe.
1 parent954a921 commitd96f139

File tree

2 files changed

+95
-117
lines changed

2 files changed

+95
-117
lines changed

‎src/pcre2_intmodedep.h‎

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -899,40 +899,37 @@ typedef struct heapframe {
899899
uint32_tgroup_frame_type;/* Type information for group frames */
900900
uint8_treturn_id;/* Where to go on in internal "return" */
901901
uint8_top;/* Processing opcode */
902+
uint8_tbyte1;/* A temporary byte to store anything */
903+
uint8_tbyte2;/* A temporary byte to store anything */
902904

903-
/* At this point, the structure is16-bit aligned. On most architectures
905+
/* At this point, the structure is32-bit aligned. On most architectures
904906
the alignment requirement for a pointer will ensure that the eptr field below
905907
is 32-bit or 64-bit aligned. However, on m68k it is fine to have a pointer
906-
that is 16-bit aligned. We must therefore ensure that what comes between here
907-
and eptr is an odd multiple of 16 bits so as to get back into 32-bit
908-
alignment. This happens naturally when PCRE2_UCHAR is 8 bits wide, but needs
909-
fudges in the other cases. In the 32-bit case the padding comes first so that
910-
the occu field itself is 32-bit aligned. Without the padding, this structure
911-
is no longer a multiple of PCRE2_SIZE on m68k, and the check below fails. */
912-
913-
#ifPCRE2_CODE_UNIT_WIDTH==8
914-
PCRE2_UCHARoccu[6];/* Used for other case code units */
915-
#elifPCRE2_CODE_UNIT_WIDTH==16
916-
PCRE2_UCHARoccu[2];/* Used for other case code units */
917-
uint8_tunused[2];/* Ensure 32-bit alignment (see above) */
918-
#else
919-
uint8_tunused[2];/* Ensure 32-bit alignment (see above) */
920-
PCRE2_UCHARoccu[1];/* Used for other case code units */
921-
#endif
908+
that is 16-bit aligned, so all uint8_t members above are required for a 32
909+
bit alignment. */
922910

923911
union {
924912
/* Fields for storing localized data, which
925913
is preserved by RMATCH() calls. */
926914

927915
struct {
928-
PCRE2_SIZElength;
929-
PCRE2_SIZEoclength;
930916
PCRE2_SPTRstart_eptr;
931917
PCRE2_SPTRcharptr;
932918
uint32_tmin;
933919
uint32_tmax;
934920
uint32_tc;
935-
uint32_toc;
921+
union {
922+
uint32_toc;
923+
/* Buffer for other case code units. The size of
924+
the buffer is enough to store the longest character. */
925+
#ifPCRE2_CODE_UNIT_WIDTH==8
926+
PCRE2_UCHARoccu[4];
927+
#elifPCRE2_CODE_UNIT_WIDTH==16
928+
PCRE2_UCHARoccu[2];
929+
#else
930+
PCRE2_UCHARoccu[1];
931+
#endif
932+
}oc;
936933
}char_repeat;
937934

938935
struct {
@@ -979,53 +976,36 @@ typedef struct heapframe {
979976
PCRE2_SIZElength;
980977
uint32_tmin;
981978
uint32_tmax;
982-
uint32_tcaseless;
983-
uint32_tcaseopts;
984979
}ref_repeat;
985980

986981
struct {
987-
PCRE2_SPTRnext_branch;/* Used only in OP_BRA handling */
988982
uint32_tframe_type;/* Set for all that use GROUPLOOP */
989983
}op_bra;
990984

991-
struct {
992-
PCRE2_SPTRnext_ecode;
993-
}op_brazero;
994-
995985
struct {
996986
PCRE2_SPTRstart_eptr;
997987
PCRE2_SPTRstart_group;
998988
uint32_tframe_type;
999-
uint32_tmatched_once;
1000-
uint32_tzero_allowed;
1001989
}op_brapos;
1002990

1003991
struct {
1004992
PCRE2_SPTRstart_branch;
1005993
uint32_tframe_type;
1006994
}op_recurse;
1007995

1008-
struct {
1009-
uint32_tframe_type;
1010-
}op_assert;
1011-
1012996
struct {
1013997
PCRE2_SPTRsaved_end_subject;
1014998
PCRE2_SPTRsaved_eptr;
1015999
PCRE2_SIZEtrue_end_extra;
1016-
uint32_tframe_type;
1017-
uint32_textra_size;
10181000
uint32_tsaved_moptions;
10191001
}op_assert_scs;
10201002

10211003
struct {
10221004
PCRE2_SPTRstart_branch;
10231005
PCRE2_SIZElength;
1024-
uint32_tpositive;
10251006
}op_cond;
10261007

10271008
struct {
1028-
PCRE2_SPTReptr;
10291009
uint32_tmin;
10301010
uint32_tmax;
10311011
}op_vreverse;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp