Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [COMMIT PATCH 1/2] savestring: Rename parameter 'size' to 'len'.
@ 2013-02-14 17:14 Pedro Alves
  2013-02-14 17:14 ` [COMMIT PATCH 2/2] Move savestring to common/common-utils.c, make gdbserver use it Pedro Alves
  2013-02-14 18:30 ` [COMMIT PATCH 1/2] savestring: Rename parameter 'size' to 'len' Mark Kettenis
  0 siblings, 2 replies; 13+ messages in thread
From: Pedro Alves @ 2013-02-14 17:14 UTC (permalink / raw)
  To: gdb-patches

It's better to avoid needless confusion, and call a string's length,
length, instead of size, which is usually used to refer to sizeof of
the string (len+1):

	size_t len = strlen (str);
	size_t size = sizeof (str);

Tested on x86_64 Fedora 17.

2013-02-14  Pedro Alves  <palves@redhat.com>

	* utils.c (savestring): Rename parameter 'size' to 'len'.
---
 gdb/utils.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/utils.c b/gdb/utils.c
index 282ab8b..408c6ce 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1186,17 +1186,17 @@ myread (int desc, char *addr, int len)
   return orglen;
 }
 
-/* Make a copy of the string at PTR with SIZE characters
+/* Make a copy of the string at PTR with LEN characters
    (and add a null character at the end in the copy).
    Uses malloc to get the space.  Returns the address of the copy.  */
 
 char *
-savestring (const char *ptr, size_t size)
+savestring (const char *ptr, size_t len)
 {
-  char *p = (char *) xmalloc (size + 1);
+  char *p = (char *) xmalloc (len + 1);
 
-  memcpy (p, ptr, size);
-  p[size] = 0;
+  memcpy (p, ptr, len);
+  p[len] = 0;
   return p;
 }
 


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

end of thread, other threads:[~2013-02-21 21:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-14 17:14 [COMMIT PATCH 1/2] savestring: Rename parameter 'size' to 'len' Pedro Alves
2013-02-14 17:14 ` [COMMIT PATCH 2/2] Move savestring to common/common-utils.c, make gdbserver use it Pedro Alves
2013-02-14 18:07   ` Tom Tromey
2013-02-14 18:08     ` Pedro Alves
2013-02-14 18:10       ` Tom Tromey
2013-02-14 18:14         ` Pedro Alves
2013-02-14 18:24           ` Tom Tromey
2013-02-14 18:31             ` Pedro Alves
2013-02-14 18:54           ` Joel Brobecker
2013-02-14 20:35             ` Tom Tromey
2013-02-14 21:05               ` Joel Brobecker
2013-02-21 21:15                 ` Tom Tromey
2013-02-14 18:30 ` [COMMIT PATCH 1/2] savestring: Rename parameter 'size' to 'len' Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox