This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

type of obstack_base: char* or void*?


The documentation says obstack_base has type `void *',
yet the code says it has type `char *':

  char	*object_base;		/* address of object we are building */
...
#define obstack_base(h) ((h)->object_base)

though the unused function prototype says it's `void *':

  void * obstack_base (struct obstack *obstack);

This came up because I found I needed a cast here,
contrary to what the documentation led me to expect:

    size_t *length = (size_t *) obstack_base (&ds->len_stack);

So which should it be?
I think the documentation is right.
Here's a patch:

2004-06-20  Jim Meyering  <jim@meyering.net>

	* malloc/obstack.h (obstack_base): Cast to `void *', to align with
	documentation.

Index: obstack.h
===================================================================
RCS file: /cvs/glibc/libc/malloc/obstack.h,v
retrieving revision 1.18
diff -u -p -r1.18 obstack.h
--- obstack.h	26 May 2004 06:37:12 -0000	1.18
+++ obstack.h	20 Jun 2004 13:35:01 -0000
@@ -194,7 +194,7 @@ extern int obstack_exit_failure;
    Note that this might not be the final address of the object
    because a new chunk might be needed to hold the final size.  */
 
-#define obstack_base(h) ((h)->object_base)
+#define obstack_base(h) (void *)((h)->object_base)
 
 /* Size for allocating ordinary chunks.  */
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]