Re: gtk_label_get_text() string duping
- From: Owen Taylor <otaylor redhat com>
- To: gtk-devel-list redhat com
- Subject: Re: gtk_label_get_text() string duping
- Date: 25 Jun 2000 23:04:31 -0400
To provide some hard data, here is most (I.e., what I could find
quickly) of the functions from glib/pango/gtk+ that return char *.
I've separated out the functions where by their very nature they need
to copy or not copy. (g_strdup, or g_utf8_next_char.)
The allocing functions outnumber the non-allocing functions about 44
to 30, though it could be argued that most of the allocing functions
alloc because they have to. (Only 10 or so are just g_strdup's of an
internal field.)
However, I don't think that rational gives the user much sense of
consistency - is it obvious that gtk_widget_name() doesn't need to
copy, but gtk_container_composite_child_name() does? is it obvious
that g_module_error() doesn't need to copy but g_win32_error_message()
does?
(This was one of two reasons that I thought we had decided on
copy-everything - in many cases you _do_ need to copy and the user
can't always know which ones. The other reason was thread safety,
especially in glib where we don't have a global lock.)
I'm not going to give an opinion on what we should do tonight - just
thought I'd throw some data out there.
Regards,
Owen
No-alloc
=======
gchar* gdk_set_locale (void);
gchar* gdk_get_display (void);
gchar* gdk_keyval_name (guint keyval);
gchar* gtk_arg_name_strip_type (const gchar *arg_name);
gchar *gtk_clist_get_column_title (GtkCList *clist,
gint column);
gint gtk_clist_get_text (GtkCList *clist,
gint row,
gint column,
gchar **text);
gint gtk_clist_get_pixtext (GtkCList *clist,
gint row,
gint column,
gchar **text,
guint8 *spacing,
GdkPixmap **pixmap,
GdkBitmap **mask);
gchar* gtk_entry_get_text (GtkEntry *entry);
void gtk_label_get (GtkLabel *label,
char **str);
gchar* gtk_set_locale (void);
gchar* gtk_file_selection_get_filename (GtkFileSelection *filesel);
gchar* gtk_font_selection_get_preview_text (GtkFontSelection *fontsel);
gchar* gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd);
gchar* gtk_signal_name (guint signal_id);
const gchar *gtk_text_buffer_get_clipboard_contents (GtkTextBuffer *buffer);
gchar* gtk_widget_get_name (GtkWidget *widget);
gchar* g_getenv (const gchar *variable);
gchar* g_strerror (gint errnum);
gchar* g_strsignal (gint signum);
gchar* g_get_user_name (void);
gchar* g_get_real_name (void);
gchar* g_get_home_dir (void);
gchar* g_get_tmp_dir (void);
gchar* g_get_prgname (void);
gchar* g_basename (const gchar *file_name);
gchar* g_path_skip_root (gchar *file_name);
gchar* g_module_error (void);
gchar* g_module_name (GModule *module);
gchar* g_type_name (GType type);
gchar* g_value_get_string (GValue *value);
Alloc
=====
gchar* gdk_atom_name (GdkAtom atom);
gchar *gtk_frame_get_label (GtkFrame *frame);
gchar *gtk_label_get_text (GtkLabel *label);
gchar* gtk_rc_get_theme_dir (void);
gchar* gtk_rc_get_module_dir (void);
char * pango_context_get_lang (PangoContext *context);
char * gtk_text_mark_get_name (GtkTextMark *mark);
gchar* g_value_dup_string (GValue *value);
gchar* gtk_accelerator_name (guint accelerator_key,
GdkModifierType accelerator_mods);
gchar* gtk_args_collect (GtkType object_type,
GHashTable *arg_info_hash_table,
GSList **arg_list_p,
GSList **info_list_p,
const gchar *first_arg_name,
va_list var_args);
gchar* gtk_arg_get_info (GtkType object_type,
GHashTable *arg_info_hash_table,
const gchar *arg_name,
GtkArgInfo **info_p);
gchar* gtk_container_child_args_collect (GtkType object_type,
GSList **arg_list_p,
GSList **info_list_p,
const gchar *first_arg_name,
va_list args);
gchar* gtk_container_child_arg_get_info (GtkType object_type,
const gchar *arg_name,
GtkArgInfo **info_p);
gchar* gtk_container_child_composite_name (GtkContainer *container,
GtkWidget *child);
gchar* gtk_editable_get_chars (GtkEditable *editable,
gint start_pos,
gint end_pos);
gchar* gtk_font_selection_get_font_name (GtkFontSelection *fontsel);
gchar* gtk_font_selection_dialog_get_font_name (GtkFontSelectionDialog *fsd);
gchar* gtk_object_args_collect (GtkType object_type,
GSList **arg_list_p,
GSList **info_list_p,
const gchar *first_arg_name,
va_list var_args);
gchar* gtk_object_arg_get_info (GtkType object_type,
const gchar *arg_name,
gchar* gtk_progress_get_current_text (GtkProgress *progress);
gchar* gtk_progress_get_text_from_value (GtkProgress *progress,
gfloat value);
gchar* gtk_rc_find_pixmap_in_path (GScanner *scanner,
const gchar *pixmap_file);
gchar* gtk_rc_find_module_in_path (const gchar *module_file);
gchar* gtk_text_buffer_get_text (GtkTextBuffer *buffer,
const GtkTextIter *start_iter,
const GtkTextIter *end_iter,
gboolean include_hidden_chars);
gchar* gtk_text_buffer_get_text_chars (GtkTextBuffer *buffer,
gint start_char,
gint end_char,
gboolean include_hidden_chars);
gchar* gtk_text_buffer_get_text_from_line (GtkTextBuffer *buffer,
gint line,
gint start_char,
gint end_char,
gboolean include_hidden_chars);
gchar* gtk_text_buffer_get_slice (GtkTextBuffer *buffer,
const GtkTextIter *start_iter,
const GtkTextIter *end_iter,
gboolean include_hidden_chars);
gchar* gtk_text_buffer_get_slice_chars (GtkTextBuffer *buffer,
gint start_char,
gint end_char,
gboolean include_hidden_chars);
gchar* gtk_text_buffer_get_slice_from_line (GtkTextBuffer *buffer,
gint line);
char * gtk_text_iter_get_slice (const GtkTextIter *start,
const GtkTextIter *end);
gchar *gtk_text_iter_get_text (const GtkTextIter *start,
const GtkTextIter *end);
gchar *gtk_text_iter_get_visible_slice (const GtkTextIter *start,
const GtkTextIter *end);
gchar *gtk_text_iter_get_visible_text (const GtkTextIter *start,
const GtkTextIter *end);
char *pango_x_make_matching_xlfd (PangoFontMap *fontmap,
char *xlfd,
const char *charset,
int size);
char *pango_x_font_subfont_xlfd (PangoFont *font,
PangoXSubfont subfont_id);
gchar* g_strcompress (const gchar *source);
gchar* g_strescape (const gchar *source,
const gchar *exceptions);
gchar* g_get_current_dir (void);
gchar *g_get_codeset (void);
gchar* g_dirname (const gchar *file_name);
gchar *g_win32_getlocale (void);
gchar *g_win32_error_message (gint error);
gchar* g_module_build_path (const gchar *directory,
const gchar *module_name);
Obvious no-copy
===============
gchar * g_utf8_offset_to_pointer (const gchar *str,
gint offset);
gchar * g_utf8_prev_char (const gchar *p);
gchar * g_utf8_find_next_char (const gchar *p,
const gchar *bound);
gchar * g_utf8_find_prev_char (const gchar *str,
gchar *g_utf8_strchr (const gchar *p,
gunichar ch);
gchar *g_utf8_strrchr (const gchar *p,
gunichar ch);
gchar* g_string_chunk_insert (GStringChunk *chunk,
const gchar *string);
gchar* g_string_chunk_insert_const (GStringChunk *chunk,
const gchar *string);
Obvious copy
============
gchar *gdk_wcstombs (const GdkWChar *src);
gchar* g_strnfill (guint length,
gchar fill_char);
gchar *g_utf8_strncpy (gchar *dest,
const gchar *src,
size_t n);
gchar * g_utf16_to_utf8 (const gunichar2 *str,
gint len);
gchar * g_ucs4_to_utf8 (const gunichar *str,
gint len);
gchar* g_strdup (const gchar *str);
gchar* g_strdup_printf (const gchar *format,
...) G_GNUC_PRINTF (1, 2);
gchar* g_strdup_vprintf (const gchar *format,
va_list args);
gchar* g_strndup (const gchar *str,
guint n);
gchar* g_strconcat (const gchar *string1,
...); /* NULL terminated */
gchar* g_strjoin (const gchar *separator,
...); /* NULL terminated */
gchar* g_strjoinv (const gchar *separator,
gchar **str_array);
gchar* g_filename_to_utf8 (const gchar *opsysstring);
gchar* g_filename_from_utf8 (const gchar *utf8string);
Modify-and-place-and-return
===========================
gchar* g_strdelimit (gchar *string,
const gchar *delimiters,
gchar new_delimiter);
gchar* g_strcanon (gchar *string,
const gchar *valid_chars,
gchar subsitutor);
gchar* g_strup (gchar *string);
gchar* g_strdown (gchar *string);
gchar* g_strreverse (gchar *string);
gchar* g_strchug (gchar *string);
gchar* g_strchomp (gchar *string);
#define g_strstrip( string ) g_strchomp (g_strchug (string))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]