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

@@ -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)
{