G_GNUC_... - MALLOC, PURE or both



I've an function which takes one argument(object) and return some
string(gchar *).
Becouse it's getting read-only propertis[1]) it shouldn't be the same
as in object.
Should I:
- Always allocate new gchar * and mark it as gchar *object_get(const
Object *) G_GNUC_MALLOC;
- Keep gchar * inside and mark it as const gchar *object_get(const
Object *) G_GNUC_PURE;
- Always allocate new gchar * and mark it as gchar *object_get(const
Object *) G_GNUC_MALLOC G_GNUC_PURE;

I'm not quite sure, but I think second is dangerous (if user cast it
into gchar and for example free it).
Thirt, I think, could allocate more strings then will be released.

Am I right?

[1] I'd like to double: getting by properties and functions.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]