From 0df4a795316ad191d499acacf9bcc924503cefdc Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Sat, 30 Nov 2024 22:42:40 -0500 Subject: [PATCH] Use memcpy to copy omit contexts. --- src/omit.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/omit.c b/src/omit.c index fe7c488e..62cf5afa 100644 --- a/src/omit.c +++ b/src/omit.c @@ -116,10 +116,9 @@ int DestroyOmitContexts(int print_unmatched) /***************************************************************/ int PushOmitContext(ParsePtr p) { - register int i; OmitContext *context; -/* Create the saved context */ + /* Create the saved context */ context = NEW(OmitContext); if (!context) return E_NO_MEM; @@ -152,14 +151,11 @@ int PushOmitContext(ParsePtr p) return E_NO_MEM; } -/* Copy the context over */ - for (i=0; ifullsave + i) = FullOmitArray[i]; + /* Copy the context over */ + memcpy(context->fullsave, FullOmitArray, NumFullOmits * sizeof(int)); + memcpy(context->partsave, PartialOmitArray, NumPartialOmits * sizeof(int)); - for (i=0; ipartsave + i) = PartialOmitArray[i]; - -/* Add the context to the stack */ + /* Add the context to the stack */ context->next = SavedOmitContexts; SavedOmitContexts = context; return VerifyEoln(p); @@ -175,7 +171,6 @@ int PushOmitContext(ParsePtr p) int PopOmitContext(ParsePtr p) { - register int i; OmitContext *c = SavedOmitContexts; if (!c) return E_POP_NO_PUSH; @@ -183,17 +178,14 @@ int PopOmitContext(ParsePtr p) NumPartialOmits = c->numpart; WeekdayOmits = c->weekdaysave; -/* Copy the context over */ - for (i=0; ifullsave + i); + /* Copy the context over */ + memcpy(FullOmitArray, c->fullsave, NumFullOmits * sizeof(int)); + memcpy(PartialOmitArray, c->partsave, NumPartialOmits * sizeof(int)); - for (i=0; ipartsave + i); - -/* Remove the context from the stack */ + /* Remove the context from the stack */ SavedOmitContexts = c->next; -/* Free memory used by the saved context */ + /* Free memory used by the saved context */ if (c->partsave) free(c->partsave); if (c->fullsave) free(c->fullsave); if (c->filename) free(c->filename);