library: the uref functions were insufficiently robust
The earlier attempt at protecting these functions from
already freed memory worked just fine until the memory
was, in fact, reused by the OS. At that point, the ref
count would most likely fail an existing a test for 0.
So this commit will take control of the 'info' pointer
and force it to NULL when a reference count reaches 0.
Plus, since it makes little sense returning an address
that a caller already has, henceforth we will return a
reference count out of the 'ref' and 'unref functions.
Reference(s):
commit 74beff80ff
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
@ -58,8 +58,8 @@ struct procps_meminfo;
|
||||
int procps_meminfo_new (struct procps_meminfo **info);
|
||||
int procps_meminfo_read (struct procps_meminfo *info);
|
||||
|
||||
struct procps_meminfo *procps_meminfo_ref (struct procps_meminfo *info);
|
||||
struct procps_meminfo *procps_meminfo_unref (struct procps_meminfo *info);
|
||||
int procps_meminfo_ref (struct procps_meminfo *info);
|
||||
int procps_meminfo_unref (struct procps_meminfo **info);
|
||||
|
||||
unsigned long procps_meminfo_get (struct procps_meminfo *info, enum meminfo_item item);
|
||||
int procps_meminfo_get_chain (struct procps_meminfo *info, struct meminfo_result *item);
|
||||
|
Reference in New Issue
Block a user