After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 163111 - Missing typedefs for SPIBoolean
Missing typedefs for SPIBoolean
Status: RESOLVED FIXED
Product: at-spi
Classification: Platform
Component: api
unspecified
Other Linux
: Normal trivial
: ---
Assigned To: bill.haneman
bill.haneman
AP3
Depends on:
Blocks:
 
 
Reported: 2005-01-06 12:09 UTC by Oana Serb
Modified: 2006-06-14 14:42 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Oana Serb 2005-01-06 12:09:56 UTC
Because in API the SPIBoolean data type exists, I consider that it should exist
the SPI_true and SPI_false values. 
Also, when clients have to free a string returned from an at-spi call, they can
be confussed and use the g_free function, instead of using the SPI_freeString
function. Because of this, I consider that it should exist a SPIChar data type.
Comment 1 bill.haneman 2005-01-06 12:31:16 UTC
I disagree about SPIChar, I don't think that's a sensible solution because
clients will want/need to use other string API with the at-spi strings. 

As for SPI_true and SPI_false, again we have multiple kinds of TRUE and FALSE
already, this seems like overkill.  That said, putting SPI_TRUE and SPI_FALSE in
the spi.h header seems reasonable.
Comment 2 remus draica 2005-01-06 13:08:12 UTC
Let's consider the next 2 pieces of code:

  gchar *name = Accessible_getName (acc)
  SPI_freeString (name)

and

  AccessibleRelation **acc_relation;
  acc_relation = Accessible_getRelationSet (acc);
  for (i = 0; acc_relation[i]; i++)
    AccessibleRelation_unref (acc_relation[i]);
  g_free (acc_relation);

As it can be seen here, user has to free 2 different pointers obtained by a call
to an at-spi function by calling an at-spi function (SPI_freeString) and a glib
function (g_free).

This may be very confussing for user. Why there is not an uniform way to deal
with all kind of pointers?
Comment 3 bill.haneman 2005-01-06 13:58:15 UTC
There is no uniform way, because the strings (while technically the same type)
are allocated from different storage.

The g_free (acc_relation) above looks wrong to me, in fact - since the
AccessibleRelation was not allocated via g_new or malloc, the relation set
should be freed with cspi-specific API.  So we should add
AccessibleRelationSet_free to the list of prototypes/macros we need.

It's quite common for client libraries to require that clients use something
other than free() or g_free() to free data structures.  In general, it's wrong
for a client to call g_free() on anything that the client did not explicitly
g_new or g_alloc(), unless the client API documentation clearly states that the
result "should be free with g_free()".

So the right solution is for clients to make no assumptions about how to free
data structures, relying on the API docs and libraries to either provide
specific 'free' API calls, or indicate which API calls should be used to free
structures.  In cases where cspi fails to do this, we should either fix the
documentation or provide appropriate ..._free() API, or both.  Using typedefs to
hint this to the user is unnecessary and is, in its own way, cumbersome and
confusing, and can lead to errors.
Comment 4 remus draica 2005-01-06 15:08:35 UTC
My example of code is inspired from at-spi/simple-at.c file. Around line 500 is
(almost) same example of processing the returned value from
Accessible_getRelationSet function.
Comment 5 bill.haneman 2005-03-03 12:08:10 UTC
the relationset and string discussion above is irrelevant to the bug (which is
concerned with the boolean return types).