Added `refcount' field. New functions to deal with refcounts.

1999-12-05  Martin Baulig  <martin@home-of-linux.org>

	* glibtop.h (glibtop): Added `refcount' field.
	* lib/init.c (glibtop_server_ref, glibtop_server_unref): New
	functions to deal with refcounts.
This commit is contained in:
Martin Baulig
1999-12-05 13:50:35 +00:00
committed by Martin Baulig
parent f5efccc8d6
commit c1cae4e9ba
3 changed files with 35 additions and 0 deletions

View File

@@ -1,5 +1,9 @@
1999-12-05 Martin Baulig <martin@home-of-linux.org>
* glibtop.h (glibtop): Added `refcount' field.
* lib/init.c (glibtop_server_ref, glibtop_server_unref): New
functions to deal with refcounts.
* structures.def: New file. This is used by the language bindings
code to get the definitions of some of LibGTop's structures.

View File

@@ -44,6 +44,7 @@ typedef struct _glibtop glibtop;
struct _glibtop
{
int refcount; /* Reference count */
unsigned flags;
unsigned method; /* Server Method */
unsigned error_method; /* Error Method */
@@ -86,6 +87,12 @@ glibtop_init_s (glibtop **server_ptr,
unsigned long features,
unsigned flags);
void
glibtop_server_ref (glibtop *server);
void
glibtop_server_unref (glibtop *server);
#ifdef GLIBTOP_GUILE
/* You need to link with -lgtop_guile to get this stuff here. */

View File

@@ -154,6 +154,30 @@ _init_server (glibtop *server, const unsigned features)
glibtop_free_r (server, command);
}
void
glibtop_server_ref (glibtop *server)
{
if (server == NULL)
return;
server->refcount++;
}
void
glibtop_server_unref (glibtop *server)
{
if (server == NULL)
return;
if (!server->refcount) {
glibtop_warn_r (server, "Attempted to unref server "
"which refcount == 0");
return;
}
server->refcount--;
}
glibtop *
glibtop_init_r (glibtop **server_ptr, unsigned long features, unsigned flags)
{