From ac07da253415ccb8b6322feedf7969967357050e Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 12 Jan 2011 23:09:29 -0800 Subject: Add XtAsprintf() as a new exported API Like asprintf() but using XtMalloc() to tie into the Xt memory allocation and error handling subsystems. Bumps libXt version to 1.0.99.1 so that modules can set their pkg-config dependency to libXt >= 1.0.99.1 to require XtAsprintf(). Signed-off-by: Alan Coopersmith --- man/Makefile.am | 3 ++- man/XtAsprintf.man | 1 + man/XtMalloc.man | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 man/XtAsprintf.man (limited to 'man') diff --git a/man/Makefile.am b/man/Makefile.am index 005c2d5..305598d 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -330,7 +330,8 @@ XtMalloc_shadows = \ XtRealloc \ XtFree \ XtNew \ - XtNewString + XtNewString \ + XtAsprintf XtManageChildren_shadows = \ XtManageChild \ diff --git a/man/XtAsprintf.man b/man/XtAsprintf.man new file mode 100644 index 0000000..50eaf76 --- /dev/null +++ b/man/XtAsprintf.man @@ -0,0 +1 @@ +.so man__libmansuffix__/XtMalloc.__libmansuffix__ diff --git a/man/XtMalloc.man b/man/XtMalloc.man index 396218b..70183ec 100644 --- a/man/XtMalloc.man +++ b/man/XtMalloc.man @@ -139,6 +139,8 @@ void XtFree(char *\fIptr\fP); \fItype\fP *XtNew(\fItype\fP); .HP String XtNewString(String \fIstring\fP); +.HP +Cardinal XtAsprintf(String *\fInew_string\fP, const char *\fIformat\fP, ...); .SH ARGUMENTS .IP \fInum\fP 1i Specifies the number of bytes or array elements. @@ -152,6 +154,10 @@ desired. Specifies a previously declared string. .IP \fItype\fP 1i Specifies a previously declared data type. +.IP \fInew_string\fP 1i +Specifies a pointer to write a newly allocated string to. +.IP \fIformat\fP 1i +Specifies a formatting string as defined by sprintf(3c) .SH DESCRIPTION The .ZN XtMalloc @@ -226,6 +232,18 @@ with the following arguments specified: .ta .5i (strcpy(XtMalloc((unsigned) strlen(str) + 1), str)) .De +.LP +The +.ZN XtAsprintf +function allocates space for a string large enough to hold the string +specified by the sprintf(3c) format pattern when used with the remaining +arguments, and fills it with the formatted results. +The address of the allocated string is placed into the pointer passed as ret. +The length of the string (not including the terminating null byte) is returned. +If there is insufficient memory to allocate the new block, +.ZN XtAsprintf +calls +.ZN XtErrorMsg . .SH "SEE ALSO" .br \fI\*(xT\fP -- cgit v1.2.3