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 #9858

Merged
merged 2 commits into from
Nov 22, 2023

Conversation

jlucovsky
Copy link
Contributor

Continuation of #9857

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:

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=

This commit modifies calls to SCCalloc that had a member count of 1 and
a size count calculated as: element_count * sizeof(element).
@victorjulien victorjulien added this to the 8.0 milestone Nov 21, 2023
@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 16676

@victorjulien victorjulien merged commit ec1482c into OISF:master Nov 22, 2023
43 checks passed
@victorjulien
Copy link
Member

Merged in #9859, thanks!

@jlucovsky jlucovsky deleted the malloc/7 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.

4 participants