IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 8, 2004, 11:06:00 AM (22 years ago)
Author:
desonia
Message:

changed behavour of psFree to print a more descriptive error message
(see bug #179) and made such an error non-fatal (no psAbort).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sysUtils/psMemory.c

    r1715 r1730  
    99*  @author Robert Lupton, Princeton University
    1010*
    11 *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2004-09-08 00:15:16 $
     11*  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2004-09-08 21:06:00 $
    1313*
    1414*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828
    2929#include "psSysUtilsErrors.h"
    30 #define ERRORNAME_PREFIX PS_ERRORNAME_DOMAIN ".psMemory."
    3130
    3231#define P_PS_MEMMAGIC (void *)0xdeadbeef   // Magic number in psMemBlock header
     
    103102{
    104103    if (ptr->refCounter < 1) {
    105         psErrorMsg(ERRORNAME_PREFIX "memProblemCallbackDefault", false, PS_ERR_MEMORY_CORRUPTION,
     104        psErrorMsg(PS_ERRORNAME_DOMAIN "memProblemCallbackDefault", false, PS_ERR_MEMORY_CORRUPTION,
    106105                   PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
    107106                   ptr->id, ptr->file, ptr->lineno, file, lineno);
     
    231230
    232231    if (m == NULL) {
    233         psErrorMsg(ERRORNAME_PREFIX "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
     232        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
    234233                   PS_ERRORTEXT_psMemory_NULL_BLOCK);
    235234        return 1;
     
    238237    if (m->refCounter == 0) {
    239238        // using an unreferenced block of memory, are you?
    240         psErrorMsg(ERRORNAME_PREFIX "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
     239        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
    241240                   PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE,
    242241                   m->id);
     
    245244
    246245    if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
    247         psErrorMsg(ERRORNAME_PREFIX "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
     246        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
    248247                   PS_ERRORTEXT_psMemory_UNDERFLOW,
    249248                   m->id);
     
    251250    }
    252251    if (*(void **)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) {
    253         psErrorMsg(ERRORNAME_PREFIX "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
     252        psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,
    254253                   PS_ERRORTEXT_psMemory_OVERFLOW,
    255254                   m->id);
     
    419418void p_psFree(void *vptr, const char *file, int lineno)
    420419{
     420    if (vptr == NULL) {
     421        return;
     422    }
     423    psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
     424    if (ptr->refCounter < 1) {
     425        psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;
     426
     427        psErrorMsg(PS_ERRORNAME_DOMAIN "psFree",PS_ERR_MEMORY_DEREF_USAGE,true,
     428                   PS_ERRORTEXT_psMemory_MULTIPLE_FREE,
     429                   ptr->id, ptr->file, ptr->lineno, file, lineno);
     430
     431        return;
     432    }
    421433    (void)p_psMemDecrRefCounter(vptr, file, lineno);    // this handles the free, if required.
    422434}
     
    535547
    536548    if (ptr->refCounter > 1) {
    537         // / XXX - Probably should have another mutex here.
    538549        ptr->refCounter--;                 // multiple references, just decrement the count.
    539550        pthread_mutex_unlock(&ptr->refCounterMutex);
Note: See TracChangeset for help on using the changeset viewer.