diff mbox

Initialize the entire obstack struct [BZ #17919]

Message ID 20150203154703.GI1528@spoyarek.pnq.redhat.com
State New
Headers show

Commit Message

Siddhesh Poyarekar Feb. 3, 2015, 3:47 p.m. UTC
On Tue, Feb 03, 2015 at 07:38:43AM -0800, H.J. Lu wrote:
> > I think you should also remove
> >
> > h->use_extra_arg = 0;
> >
> 
> And
> 
>   /* The initial chunk now contains no empty object.  */
>   h->maybe_empty_object = 0;
>   h->alloc_failed = 0;

Done.  Verified on s390x.

Siddhesh

ChangeLog for gnulib:

	obstack: Initialize whole obstack structure.
	* lib/obstack.c (_obstack_begin): Initialize all of H.

ChangeLog for glibc:

	[BZ #17919]
	* malloc/obstack.c (_obstack_begin): Initialize all of H.

Comments

H.J. Lu Feb. 3, 2015, 3:48 p.m. UTC | #1
On Tue, Feb 3, 2015 at 7:47 AM, Siddhesh Poyarekar <siddhesh@redhat.com> wrote:
> On Tue, Feb 03, 2015 at 07:38:43AM -0800, H.J. Lu wrote:
>> > I think you should also remove
>> >
>> > h->use_extra_arg = 0;
>> >
>>
>> And
>>
>>   /* The initial chunk now contains no empty object.  */
>>   h->maybe_empty_object = 0;
>>   h->alloc_failed = 0;
>
> Done.  Verified on s390x.
>
> Siddhesh
>
> ChangeLog for gnulib:
>
>         obstack: Initialize whole obstack structure.
>         * lib/obstack.c (_obstack_begin): Initialize all of H.
>
> ChangeLog for glibc:
>
>         [BZ #17919]
>         * malloc/obstack.c (_obstack_begin): Initialize all of H.
>
>
> diff --git a/malloc/obstack.c b/malloc/obstack.c
> index 5bb3f0d..1957402 100644
> --- a/malloc/obstack.c
> +++ b/malloc/obstack.c
> @@ -148,6 +148,8 @@ _obstack_begin (struct obstack *h,
>  {
>    struct _obstack_chunk *chunk; /* points to new chunk */
>
> +  memset (h, 0, sizeof (struct obstack));
> +
>    if (alignment == 0)
>      alignment = DEFAULT_ALIGNMENT;
>    if (size == 0)
> @@ -171,7 +173,6 @@ _obstack_begin (struct obstack *h,
>    h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
>    h->chunk_size = size;
>    h->alignment_mask = alignment - 1;
> -  h->use_extra_arg = 0;
>
>    chunk = h->chunk = CALL_CHUNKFUN (h, h->chunk_size);
>    if (!chunk)
> @@ -181,9 +182,6 @@ _obstack_begin (struct obstack *h,
>    h->chunk_limit = chunk->limit
>      = (char *) chunk + h->chunk_size;
>    chunk->prev = 0;
> -  /* The initial chunk now contains no empty object.  */
> -  h->maybe_empty_object = 0;
> -  h->alloc_failed = 0;
>    return 1;
>  }
>

Looks good to me for 2.22.

Thanks.
diff mbox

Patch

diff --git a/malloc/obstack.c b/malloc/obstack.c
index 5bb3f0d..1957402 100644
--- a/malloc/obstack.c
+++ b/malloc/obstack.c
@@ -148,6 +148,8 @@  _obstack_begin (struct obstack *h,
 {
   struct _obstack_chunk *chunk; /* points to new chunk */
 
+  memset (h, 0, sizeof (struct obstack));
+
   if (alignment == 0)
     alignment = DEFAULT_ALIGNMENT;
   if (size == 0)
@@ -171,7 +173,6 @@  _obstack_begin (struct obstack *h,
   h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
   h->chunk_size = size;
   h->alignment_mask = alignment - 1;
-  h->use_extra_arg = 0;
 
   chunk = h->chunk = CALL_CHUNKFUN (h, h->chunk_size);
   if (!chunk)
@@ -181,9 +182,6 @@  _obstack_begin (struct obstack *h,
   h->chunk_limit = chunk->limit
     = (char *) chunk + h->chunk_size;
   chunk->prev = 0;
-  /* The initial chunk now contains no empty object.  */
-  h->maybe_empty_object = 0;
-  h->alloc_failed = 0;
   return 1;
 }