Re: g_malloc overhead
- From: muppet <scott asofyet org>
- To: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: g_malloc overhead
- Date: Thu, 29 Jan 2009 23:12:10 -0500
On Jan 29, 2009, at 2:44 PM, Tor Lillqvist wrote:
this is even more true if you see there's a memcpy() function that
is quite
the same as what strncpy() is.
No it isn't. strncpy() stops when it encounters a zero char (byte).
memcpy() always copies exactly the requested number of chars (bytes).
It's even more confusing than that. strncpy() will touch n bytes. If
a nul is encountered in the source string before reaching n, then from
there to n will be filled with zeroes. If it reaches n before
reaching the end of the source string, it simply stops, without
terminating. Hence the creation of strlcpy().
http://www.gratisoft.us/todd/papers/strlcpy.html
http://www.gtk.org/api/2.6/glib/glib-String-Utility-Functions.html#g-strlcpy
--
Doing a good job around here is like wetting your pants in a dark
suit; you get a warm feeling, but no one notices.
-- unknown
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]