diff options
author | Pedro Alves <palves@redhat.com> | 2013-02-14 17:09:00 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2013-02-14 17:09:00 +0000 |
commit | 57c3b6ede58a103b97baa10bef7d9d9031d2269b (patch) | |
tree | 6edf764e3b43b65853bd747c3b39c610b7d3cbf2 /gdb | |
parent | 420f4384af4aac17ca68d8834519f18d6dbe0ee6 (diff) | |
download | gdb-57c3b6ede58a103b97baa10bef7d9d9031d2269b.zip gdb-57c3b6ede58a103b97baa10bef7d9d9031d2269b.tar.gz gdb-57c3b6ede58a103b97baa10bef7d9d9031d2269b.tar.bz2 |
savestring: Rename parameter 'size' to 'len'.
It's better to avoid needless confusion, and call string 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'.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/utils.c | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9523824..3e91b36 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,4 +1,8 @@ 2013-02-14 Pedro Alves <palves@redhat.com> + + * utils.c (savestring): Rename parameter 'size' to 'len'. + +2013-02-14 Pedro Alves <palves@redhat.com> Yufeng Zhang <yufeng.zhang@arm.com> * aarch64-linux-nat.c (aarch64_init_debug_reg_state): Delete. 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; } |