Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory/alloc: Use SCCalloc instead of malloc/memset #9857

Closed
wants to merge 4 commits into from

Conversation

jlucovsky
Copy link
Contributor

@jlucovsky jlucovsky commented Nov 21, 2023

Continuation of #9845

Replace SCMalloc/memset with SCCalloc

There are many places that use the following pattern:

     mem = SCMalloc(sizeof(foo));
     if (mem) {
        memset(&mem, 0, sizeof(foo));
    }

These can all be replaced by using SCCalloc which returns 0-filled memory.

Describe changes:

  • Changed SCMalloc followed by memset to SCCalloc

Updates:

  • Rebase
  • Convert SCCalloc(1, element_count * sizeof(element)) to SCCalloc(element_count, sizeof(element))

Provide values to any of the below to override the defaults.

To use a pull request use a branch name like pr/N where N is the
pull request number.

Alternatively, SV_BRANCH may also be a link to an
OISF/suricata-verify pull-request.

SV_REPO=
SV_BRANCH=
SU_REPO=
SU_BRANCH=
LIBHTP_REPO=
LIBHTP_BRANCH=

catenacyber and others added 4 commits November 21, 2023 09:19
Ticket: OISF#6104

And failures should be handled to say that the rule failed to load

Reverts the fix by 299ee6e
that was simple, but not complete (memory leak),
to have this bigger API change which simplifies code.
Ticket: OISF#6104

And failures should be handled to say that the rule failed to load

Reverts the fix by 299ee6e
that was simple, but not complete (memory leak),
to have this bigger API change which simplifies code.
This commit modifies calls to SCCalloc that had a member count of 1 and
a size count calculated as: element_count * sizeof(element).
@jlucovsky
Copy link
Contributor Author

Continued in #9858

@jlucovsky jlucovsky deleted the malloc/6 branch November 22, 2023 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants