#683 closed defect (fixed)
Memory bugs
| Reported by: | Paul Price | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | sys | Version: | unspecified |
| Severity: | normal | Keywords: | |
| Cc: |
Description
psMemIncrRefCounter should include a check for the allocation callback (helpful
for tracing down memory leaks).
psMetatadataLookupStr and psMetadataLookupMD return a ptr that has to be
psFree-ed by the user, contrary to the policy for the other functions (resulting
in memory leaks). We need to settle on a consistent policy for lookup-type
functions within pslib, but for the time being, we should remove the incremented
reference counter on these functions.
Change History (6)
comment:1 by , 20 years ago
comment:2 by , 20 years ago
And psMemIncrRefCounter:
increment and return refCounter
psPtr p_psMemIncrRefCounter(psPtr vptr,
const char *file,
psS32 lineno)
{
psMemBlock* ptr;
if (vptr == NULL) {
return vptr;
}
ptr = ((psMemBlock* ) vptr) - 1;
if (checkMemBlock(ptr, func)) {
memProblemCallback(ptr, file, lineno);
}
pthread_mutex_lock(&ptr->refCounterMutex);
ptr->refCounter++;
pthread_mutex_unlock(&ptr->refCounterMutex);
Did the user ask to be informed about this allocation?
if (ptr->id == p_psMemAllocID) {
p_psMemAllocID += memAllocCallback(ptr);
}
return vptr;
}
comment:3 by , 20 years ago
| Owner: | changed from to |
|---|
comment:4 by , 20 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
made changes to psMetadataLookupPtr, psMetadataLookupStr, and psMetadataLookupMD to remove the
memory reference increment. Also searched and changed any code using these functions.
Also added the change to p_psMemIncrRefCounter as suggested.
-rdd

Here's fixed versions of the psMetadataLookupStr and psMetadataLookupMD:
psMetadata *psMetadataLookupMD(bool *status,
{
metadata with instruments
expected.\n");
}
psString psMetadataLookupStr(bool *status,
{
metadata with instruments
expected.\n");
}