All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix calloc() and xcalloc() argument ordering
@ 2014-08-30  6:54 Arjun Sreedharan
  2014-09-02 18:42 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Arjun Sreedharan @ 2014-08-30  6:54 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

@number first, @size second argument.

Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
---
 builtin/for-each-ref.c        |  2 +-
 compat/regex/regcomp.c        | 12 ++++++------
 compat/regex/regex_internal.c |  4 ++--
 compat/regex/regexec.c        | 10 +++++-----
 imap-send.c                   |  2 +-
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 47bd624..69bba06 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -633,7 +633,7 @@ static void populate_value(struct refinfo *ref)
 	unsigned long size;
 	const unsigned char *tagged;
 
-	ref->value = xcalloc(sizeof(struct atom_value), used_atom_cnt);
+	ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
 
 	if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
 		unsigned char unused1[20];
diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c
index 06f3088..e375c50 100644
--- a/compat/regex/regcomp.c
+++ b/compat/regex/regcomp.c
@@ -861,7 +861,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
     if (table_size > pat_len)
       break;
 
-  dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
+  dfa->state_table = calloc (table_size, sizeof (struct re_state_table_entry));
   dfa->state_hash_mask = table_size - 1;
 
   dfa->mb_cur_max = MB_CUR_MAX;
@@ -929,7 +929,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
 	{
 	  int i, j, ch;
 
-	  dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+	  dfa->sb_char = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
 	  if (BE (dfa->sb_char == NULL, 0))
 	    return REG_ESPACE;
 
@@ -3072,9 +3072,9 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
 						   _NL_COLLATE_SYMB_EXTRAMB);
     }
 #endif
-  sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+  sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
 #ifdef RE_ENABLE_I18N
-  mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+  mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
 #endif /* RE_ENABLE_I18N */
 #ifdef RE_ENABLE_I18N
   if (BE (sbcset == NULL || mbcset == NULL, 0))
@@ -3619,9 +3619,9 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
   re_token_t br_token;
   bin_tree_t *tree;
 
-  sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+  sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
 #ifdef RE_ENABLE_I18N
-  mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+  mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
 #endif /* RE_ENABLE_I18N */
 
 #ifdef RE_ENABLE_I18N
diff --git a/compat/regex/regex_internal.c b/compat/regex/regex_internal.c
index d4121f2..9d9e986 100644
--- a/compat/regex/regex_internal.c
+++ b/compat/regex/regex_internal.c
@@ -1629,7 +1629,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
   reg_errcode_t err;
   re_dfastate_t *newstate;
 
-  newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+  newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
   if (BE (newstate == NULL, 0))
     return NULL;
   err = re_node_set_init_copy (&newstate->nodes, nodes);
@@ -1679,7 +1679,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
   reg_errcode_t err;
   re_dfastate_t *newstate;
 
-  newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+  newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
   if (BE (newstate == NULL, 0))
     return NULL;
   err = re_node_set_init_copy (&newstate->nodes, nodes);
diff --git a/compat/regex/regexec.c b/compat/regex/regexec.c
index eb5e1d4..edfe0c6 100644
--- a/compat/regex/regexec.c
+++ b/compat/regex/regexec.c
@@ -2797,8 +2797,8 @@ get_subexp (re_match_context_t *mctx, int bkref_node, int bkref_str_idx)
 	    continue; /* No.  */
 	  if (sub_top->path == NULL)
 	    {
-	      sub_top->path = calloc (sizeof (state_array_t),
-				      sl_str - sub_top->str_idx + 1);
+	      sub_top->path = calloc (sl_str - sub_top->str_idx + 1,
+				      sizeof (state_array_t));
 	      if (sub_top->path == NULL)
 		return REG_ESPACE;
 	    }
@@ -3362,7 +3362,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
       if (ndests == 0)
 	{
 	  state->trtable = (re_dfastate_t **)
-	    calloc (sizeof (re_dfastate_t *), SBC_MAX);
+	    calloc (SBC_MAX, sizeof (re_dfastate_t *));
 	  return 1;
 	}
       return 0;
@@ -3458,7 +3458,7 @@ out_free:
 	 discern by looking at the character code: allocate a
 	 256-entry transition table.  */
       trtable = state->trtable =
-	(re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
+	(re_dfastate_t **) calloc (SBC_MAX, sizeof (re_dfastate_t *));
       if (BE (trtable == NULL, 0))
 	goto out_free;
 
@@ -3489,7 +3489,7 @@ out_free:
 	 transition tables, one starting at trtable[0] and one
 	 starting at trtable[SBC_MAX].  */
       trtable = state->word_trtable =
-	(re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
+	(re_dfastate_t **) calloc (2 * SBC_MAX, sizeof (re_dfastate_t *));
       if (BE (trtable == NULL, 0))
 	goto out_free;
 
diff --git a/imap-send.c b/imap-send.c
index 524fbab..02eb3e0 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -954,7 +954,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc)
 
 	ctx = xcalloc(1, sizeof(*ctx));
 
-	ctx->imap = imap = xcalloc(sizeof(*imap), 1);
+	ctx->imap = imap = xcalloc(1, sizeof(*imap));
 	imap->buf.sock.fd[0] = imap->buf.sock.fd[1] = -1;
 	imap->in_progress_append = &imap->in_progress;
 
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fix calloc() and xcalloc() argument ordering
  2014-08-30  6:54 [PATCH] fix calloc() and xcalloc() argument ordering Arjun Sreedharan
@ 2014-09-02 18:42 ` Junio C Hamano
  2014-09-03  6:30   ` Arjun Sreedharan
  2014-09-04 14:03   ` Arjun Sreedharan
  0 siblings, 2 replies; 4+ messages in thread
From: Junio C Hamano @ 2014-09-02 18:42 UTC (permalink / raw)
  To: Arjun Sreedharan; +Cc: git

Arjun Sreedharan <arjun024@gmail.com> writes:

> @number first, @size second argument.
>
> Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
> ---
>  builtin/for-each-ref.c        |  2 +-

Thanks.  compat/regex/ being borrowed code, I'd prefer not to touch
them, though.

>  compat/regex/regcomp.c        | 12 ++++++------
>  compat/regex/regex_internal.c |  4 ++--
>  compat/regex/regexec.c        | 10 +++++-----
>  imap-send.c                   |  2 +-
>  5 files changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
> index 47bd624..69bba06 100644
> --- a/builtin/for-each-ref.c
> +++ b/builtin/for-each-ref.c
> @@ -633,7 +633,7 @@ static void populate_value(struct refinfo *ref)
>  	unsigned long size;
>  	const unsigned char *tagged;
>  
> -	ref->value = xcalloc(sizeof(struct atom_value), used_atom_cnt);
> +	ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
>  
>  	if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
>  		unsigned char unused1[20];
> diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c
> index 06f3088..e375c50 100644
> --- a/compat/regex/regcomp.c
> +++ b/compat/regex/regcomp.c
> @@ -861,7 +861,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
>      if (table_size > pat_len)
>        break;
>  
> -  dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
> +  dfa->state_table = calloc (table_size, sizeof (struct re_state_table_entry));
>    dfa->state_hash_mask = table_size - 1;
>  
>    dfa->mb_cur_max = MB_CUR_MAX;
> @@ -929,7 +929,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
>  	{
>  	  int i, j, ch;
>  
> -	  dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
> +	  dfa->sb_char = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
>  	  if (BE (dfa->sb_char == NULL, 0))
>  	    return REG_ESPACE;
>  
> @@ -3072,9 +3072,9 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
>  						   _NL_COLLATE_SYMB_EXTRAMB);
>      }
>  #endif
> -  sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
> +  sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
>  #ifdef RE_ENABLE_I18N
> -  mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
> +  mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
>  #endif /* RE_ENABLE_I18N */
>  #ifdef RE_ENABLE_I18N
>    if (BE (sbcset == NULL || mbcset == NULL, 0))
> @@ -3619,9 +3619,9 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
>    re_token_t br_token;
>    bin_tree_t *tree;
>  
> -  sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
> +  sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
>  #ifdef RE_ENABLE_I18N
> -  mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
> +  mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
>  #endif /* RE_ENABLE_I18N */
>  
>  #ifdef RE_ENABLE_I18N
> diff --git a/compat/regex/regex_internal.c b/compat/regex/regex_internal.c
> index d4121f2..9d9e986 100644
> --- a/compat/regex/regex_internal.c
> +++ b/compat/regex/regex_internal.c
> @@ -1629,7 +1629,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
>    reg_errcode_t err;
>    re_dfastate_t *newstate;
>  
> -  newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
> +  newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
>    if (BE (newstate == NULL, 0))
>      return NULL;
>    err = re_node_set_init_copy (&newstate->nodes, nodes);
> @@ -1679,7 +1679,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
>    reg_errcode_t err;
>    re_dfastate_t *newstate;
>  
> -  newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
> +  newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
>    if (BE (newstate == NULL, 0))
>      return NULL;
>    err = re_node_set_init_copy (&newstate->nodes, nodes);
> diff --git a/compat/regex/regexec.c b/compat/regex/regexec.c
> index eb5e1d4..edfe0c6 100644
> --- a/compat/regex/regexec.c
> +++ b/compat/regex/regexec.c
> @@ -2797,8 +2797,8 @@ get_subexp (re_match_context_t *mctx, int bkref_node, int bkref_str_idx)
>  	    continue; /* No.  */
>  	  if (sub_top->path == NULL)
>  	    {
> -	      sub_top->path = calloc (sizeof (state_array_t),
> -				      sl_str - sub_top->str_idx + 1);
> +	      sub_top->path = calloc (sl_str - sub_top->str_idx + 1,
> +				      sizeof (state_array_t));
>  	      if (sub_top->path == NULL)
>  		return REG_ESPACE;
>  	    }
> @@ -3362,7 +3362,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
>        if (ndests == 0)
>  	{
>  	  state->trtable = (re_dfastate_t **)
> -	    calloc (sizeof (re_dfastate_t *), SBC_MAX);
> +	    calloc (SBC_MAX, sizeof (re_dfastate_t *));
>  	  return 1;
>  	}
>        return 0;
> @@ -3458,7 +3458,7 @@ out_free:
>  	 discern by looking at the character code: allocate a
>  	 256-entry transition table.  */
>        trtable = state->trtable =
> -	(re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
> +	(re_dfastate_t **) calloc (SBC_MAX, sizeof (re_dfastate_t *));
>        if (BE (trtable == NULL, 0))
>  	goto out_free;
>  
> @@ -3489,7 +3489,7 @@ out_free:
>  	 transition tables, one starting at trtable[0] and one
>  	 starting at trtable[SBC_MAX].  */
>        trtable = state->word_trtable =
> -	(re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
> +	(re_dfastate_t **) calloc (2 * SBC_MAX, sizeof (re_dfastate_t *));
>        if (BE (trtable == NULL, 0))
>  	goto out_free;
>  
> diff --git a/imap-send.c b/imap-send.c
> index 524fbab..02eb3e0 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -954,7 +954,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc)
>  
>  	ctx = xcalloc(1, sizeof(*ctx));
>  
> -	ctx->imap = imap = xcalloc(sizeof(*imap), 1);
> +	ctx->imap = imap = xcalloc(1, sizeof(*imap));
>  	imap->buf.sock.fd[0] = imap->buf.sock.fd[1] = -1;
>  	imap->in_progress_append = &imap->in_progress;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fix calloc() and xcalloc() argument ordering
  2014-09-02 18:42 ` Junio C Hamano
@ 2014-09-03  6:30   ` Arjun Sreedharan
  2014-09-04 14:03   ` Arjun Sreedharan
  1 sibling, 0 replies; 4+ messages in thread
From: Arjun Sreedharan @ 2014-09-03  6:30 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 3 September 2014 00:12, Junio C Hamano <gitster@pobox.com> wrote:
> Arjun Sreedharan <arjun024@gmail.com> writes:
>
>> @number first, @size second argument.
>>
>> Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
>> ---
>>  builtin/for-each-ref.c        |  2 +-
>
> Thanks.  compat/regex/ being borrowed code, I'd prefer not to touch
> them, though.
>

Ok. should i resend?

>>  compat/regex/regcomp.c        | 12 ++++++------
>>  compat/regex/regex_internal.c |  4 ++--
>>  compat/regex/regexec.c        | 10 +++++-----
>>  imap-send.c                   |  2 +-
>>  5 files changed, 15 insertions(+), 15 deletions(-)
>>
>> diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
>> index 47bd624..69bba06 100644
>> --- a/builtin/for-each-ref.c
>> +++ b/builtin/for-each-ref.c
>> @@ -633,7 +633,7 @@ static void populate_value(struct refinfo *ref)
>>       unsigned long size;
>>       const unsigned char *tagged;
>>
>> -     ref->value = xcalloc(sizeof(struct atom_value), used_atom_cnt);
>> +     ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
>>
>>       if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
>>               unsigned char unused1[20];
>> diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c
>> index 06f3088..e375c50 100644
>> --- a/compat/regex/regcomp.c
>> +++ b/compat/regex/regcomp.c
>> @@ -861,7 +861,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
>>      if (table_size > pat_len)
>>        break;
>>
>> -  dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
>> +  dfa->state_table = calloc (table_size, sizeof (struct re_state_table_entry));
>>    dfa->state_hash_mask = table_size - 1;
>>
>>    dfa->mb_cur_max = MB_CUR_MAX;
>> @@ -929,7 +929,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
>>       {
>>         int i, j, ch;
>>
>> -       dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
>> +       dfa->sb_char = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
>>         if (BE (dfa->sb_char == NULL, 0))
>>           return REG_ESPACE;
>>
>> @@ -3072,9 +3072,9 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
>>                                                  _NL_COLLATE_SYMB_EXTRAMB);
>>      }
>>  #endif
>> -  sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
>> +  sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
>>  #ifdef RE_ENABLE_I18N
>> -  mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
>> +  mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
>>  #endif /* RE_ENABLE_I18N */
>>  #ifdef RE_ENABLE_I18N
>>    if (BE (sbcset == NULL || mbcset == NULL, 0))
>> @@ -3619,9 +3619,9 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
>>    re_token_t br_token;
>>    bin_tree_t *tree;
>>
>> -  sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
>> +  sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
>>  #ifdef RE_ENABLE_I18N
>> -  mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
>> +  mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
>>  #endif /* RE_ENABLE_I18N */
>>
>>  #ifdef RE_ENABLE_I18N
>> diff --git a/compat/regex/regex_internal.c b/compat/regex/regex_internal.c
>> index d4121f2..9d9e986 100644
>> --- a/compat/regex/regex_internal.c
>> +++ b/compat/regex/regex_internal.c
>> @@ -1629,7 +1629,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
>>    reg_errcode_t err;
>>    re_dfastate_t *newstate;
>>
>> -  newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
>> +  newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
>>    if (BE (newstate == NULL, 0))
>>      return NULL;
>>    err = re_node_set_init_copy (&newstate->nodes, nodes);
>> @@ -1679,7 +1679,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
>>    reg_errcode_t err;
>>    re_dfastate_t *newstate;
>>
>> -  newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
>> +  newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
>>    if (BE (newstate == NULL, 0))
>>      return NULL;
>>    err = re_node_set_init_copy (&newstate->nodes, nodes);
>> diff --git a/compat/regex/regexec.c b/compat/regex/regexec.c
>> index eb5e1d4..edfe0c6 100644
>> --- a/compat/regex/regexec.c
>> +++ b/compat/regex/regexec.c
>> @@ -2797,8 +2797,8 @@ get_subexp (re_match_context_t *mctx, int bkref_node, int bkref_str_idx)
>>           continue; /* No.  */
>>         if (sub_top->path == NULL)
>>           {
>> -           sub_top->path = calloc (sizeof (state_array_t),
>> -                                   sl_str - sub_top->str_idx + 1);
>> +           sub_top->path = calloc (sl_str - sub_top->str_idx + 1,
>> +                                   sizeof (state_array_t));
>>             if (sub_top->path == NULL)
>>               return REG_ESPACE;
>>           }
>> @@ -3362,7 +3362,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
>>        if (ndests == 0)
>>       {
>>         state->trtable = (re_dfastate_t **)
>> -         calloc (sizeof (re_dfastate_t *), SBC_MAX);
>> +         calloc (SBC_MAX, sizeof (re_dfastate_t *));
>>         return 1;
>>       }
>>        return 0;
>> @@ -3458,7 +3458,7 @@ out_free:
>>        discern by looking at the character code: allocate a
>>        256-entry transition table.  */
>>        trtable = state->trtable =
>> -     (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
>> +     (re_dfastate_t **) calloc (SBC_MAX, sizeof (re_dfastate_t *));
>>        if (BE (trtable == NULL, 0))
>>       goto out_free;
>>
>> @@ -3489,7 +3489,7 @@ out_free:
>>        transition tables, one starting at trtable[0] and one
>>        starting at trtable[SBC_MAX].  */
>>        trtable = state->word_trtable =
>> -     (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
>> +     (re_dfastate_t **) calloc (2 * SBC_MAX, sizeof (re_dfastate_t *));
>>        if (BE (trtable == NULL, 0))
>>       goto out_free;
>>
>> diff --git a/imap-send.c b/imap-send.c
>> index 524fbab..02eb3e0 100644
>> --- a/imap-send.c
>> +++ b/imap-send.c
>> @@ -954,7 +954,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc)
>>
>>       ctx = xcalloc(1, sizeof(*ctx));
>>
>> -     ctx->imap = imap = xcalloc(sizeof(*imap), 1);
>> +     ctx->imap = imap = xcalloc(1, sizeof(*imap));
>>       imap->buf.sock.fd[0] = imap->buf.sock.fd[1] = -1;
>>       imap->in_progress_append = &imap->in_progress;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] fix calloc() and xcalloc() argument ordering
  2014-09-02 18:42 ` Junio C Hamano
  2014-09-03  6:30   ` Arjun Sreedharan
@ 2014-09-04 14:03   ` Arjun Sreedharan
  1 sibling, 0 replies; 4+ messages in thread
From: Arjun Sreedharan @ 2014-09-04 14:03 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

@number first, @size second argument.

Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
---
 builtin/for-each-ref.c | 2 +-
 imap-send.c            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 47bd624..69bba06 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -633,7 +633,7 @@ static void populate_value(struct refinfo *ref)
 	unsigned long size;
 	const unsigned char *tagged;
 
-	ref->value = xcalloc(sizeof(struct atom_value), used_atom_cnt);
+	ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
 
 	if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
 		unsigned char unused1[20];
diff --git a/imap-send.c b/imap-send.c
index 524fbab..02eb3e0 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -954,7 +954,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc)
 
 	ctx = xcalloc(1, sizeof(*ctx));
 
-	ctx->imap = imap = xcalloc(sizeof(*imap), 1);
+	ctx->imap = imap = xcalloc(1, sizeof(*imap));
 	imap->buf.sock.fd[0] = imap->buf.sock.fd[1] = -1;
 	imap->in_progress_append = &imap->in_progress;
 
-- 
1.8.1.msysgit.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-04 14:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-30  6:54 [PATCH] fix calloc() and xcalloc() argument ordering Arjun Sreedharan
2014-09-02 18:42 ` Junio C Hamano
2014-09-03  6:30   ` Arjun Sreedharan
2014-09-04 14:03   ` Arjun Sreedharan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.