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

utstring.h: fix wrong sequence of parameters calling calloc(). #141

Closed
wants to merge 1 commit into from
Closed

Conversation

silvioprog
Copy link

@silvioprog silvioprog commented Feb 9, 2018

Hello.

According to man 3 calloc, the first parameter of calloc() function is the nmemb of elements:

SYNOPSIS

...

       void *calloc(size_t nmemb, size_t size);

...

DESCRIPTION

...

       The  calloc()  function allocates memory for an array of nmemb elements
       of size bytes each and returns a pointer to the allocated memory.   The
       memory  is  set  to zero.  If nmemb or size is 0, then calloc() returns
       either NULL, or a unique pointer value that can later  be  successfully
       passed to free().

So this PR should fix it.

(notice it was property used here).

Thank you!

Copy link
Contributor

@tbeu tbeu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Quuxplusone
Copy link
Collaborator

Quuxplusone commented Feb 9, 2018

LGTM, but I'd be inclined to merge 1dd1d23 instead, because I don't see why we need calloc at all. Anyone feel like defending calloc here?
Otherwise I'll merge 1dd1d23 in a few days.

Issue #94 is tangentially related, btw.

@silvioprog
Copy link
Author

Since utstring_init() already zero-initializes the structure, +1 for pure malloc() since . 😃

@silvioprog
Copy link
Author

Closing to merge 1dd1d23 as better fixing.

@silvioprog silvioprog closed this Feb 9, 2018
@silvioprog
Copy link
Author

Thanks dudes! 👍 😃 👍

silvioprog added a commit to risoflora/libsagui that referenced this pull request Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants