Alan Coopersmith wrote:
> Menno Lageman wrote:
>
>> Glynn Foster wrote:
>>
>>> Hey,
>>>
>>> James Litchfield wrote:
>>>
>>>> Fired up prstat the other day and noticed something new: gam_server was
>>>> running around madly stating files. This seems to be
>>>>
>>>> http://www.gnome.org/~veillard/gamin/
>>>>
>>>> The obvious question is why not use the Solaris file monitoring
>>>> capabilities instead of stating the world away....
>>>>
>>> Gamin is currently built with a patch that should enable Solaris' FEM -
>>>
>>> http://src.opensolaris.org/source/xref/jds/spec-files/trunk/patches/gamin-01-all.diff
>>>
>>> hopefully others on the list will be able to say why it's behaving this way.
>>>
>>>
>> Hmmm,
>>
>> is this a finished patch? A cursory look turns up this:
>>
>
> It also seems to have a useless malloc that results in a memory leak:
>
> 103 +#elif defined(HAVE_GETPEERUCRED)
> 104 + if ((creds = (ucred_t *)malloc(ucred_size()))==(ucred_t
> *)NULL){
> 105 + GAM_DEBUG(DEBUG_INFO,"Malloc failed for ucreds");
> 106 + goto failed;
> 107 + }
> 108 +
> 109 + if (getpeerucred(fd, &creds)!=0){
> 110 + GAM_DEBUG(DEBUG_INFO,"getpeerucred call failed");
> 111 + goto failed;
> 112 + }
>
> getpeerucred allocates and returns the ucred structure - you don't need
> to preallocate it.
>
>
Alan,
Below is a from 'man getpeerucred'. If the manual page is correct
you do not have to preallocate it as you say. Though it should not
allocate any new memory if the ucred structure has already been allocated.
Doug
When successful, getpeerucred() stores the pointer to a
freshly allocated ucred_t in the memory location pointed to
by the ucred argument if that memory location contains the
null pointer. If the memory location is non-null, it will
reuse the existing ucred_t.