Re: g_strndup()
- From: Damon Chaplin <damon helixcode com>
- To: "David C. Mason" <dcm redhat com>
- Cc: gtk-doc-list gnome org
- Subject: Re: g_strndup()
- Date: Mon, 26 Jun 2000 20:29:36 +0100
"David C. Mason" wrote:
>
> Hi guys,
>
> Robey Pointer from Eazel pointed this out to me...
>
> > The glib documentation states that for g_strndup(), "n" must be less
> > than or equal to the length of the original string. That's not
> > true: "n" can be greater than the length of the string. More memory
> > will be allocated than you necessarily needed, but the returned
> > string will be of length <= n, and it will be null terminated, so
> > the end result is success.
>
> Is this correct? Should we update as such?
Yes, it is correct.
I'll change it to this, unless someone suggests something better:
<!-- ##### FUNCTION g_strndup ##### -->
<para>
Duplicates the first @n characters of a string, returning a newly-allocated
buffer @n + 1 characters long which will always be null-terminated.
If @str is less than @n characters long the buffer is padded with nulls.
The returned value should be freed when no longer needed.
</para>
@str: the string to duplicate part of.
@n: the maximum number of characters to copy from @str.
@Returns: a newly-allocated buffer containing the first @n characters of @str,
null-terminated.
Damon
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]