IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 469


Ignore:
Timestamp:
Apr 19, 2004, 4:58:46 PM (22 years ago)
Author:
desonia
Message:

testing commitinfo.

Location:
trunk/psLib/src
Files:
2 edited

Legend:

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

    r468 r469  
    88 *  @author Robert Lupton, Princeton University
    99 *
    10  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-04-20 02:52:48 $
     10 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-04-20 02:58:46 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4848    psMemExhaustedCallback old = memExhaustedCallback;
    4949
    50     if (func != NULL) {
     50    if (func != NULL)
     51    {
    5152        memExhaustedCallback = func;
    52     } else {
     53    }
     54    else
     55    {
    5356        memExhaustedCallback = memExhaustedCallbackDefault;
    5457    }
     
    6265    checkMemBlock(ptr, __func__);
    6366
    64     if (ptr->refCounter <= 0) {
     67    if (ptr->refCounter <= 0)
     68    {
    6569        psError(__func__,
    6670                "Block %ld allocated at %s:%d freed more than once at %s:%d\n",
    6771                ptr->id, ptr->file, ptr->lineno, file, lineno);
    68     } else if (ptr->refCounter > 1) {
     72    }
     73    else if (ptr->refCounter > 1)
     74    {
    6975        psError(__func__,
    7076                "Block %ld allocated at %s:%d freed while still referenced at %s:%d\n",
     
    7278    }
    7379
    74     if (lineno > 0) {
     80    if (lineno > 0)
     81    {
    7582        psAbort(__func__, "Detected a problem in the memory system at %s:%d", file, lineno);
    7683    }
     
    8289    psMemProblemCallback old = memProblemCallback;
    8390
    84     if (func != NULL) {
     91    if (func != NULL)
     92    {
    8593        memProblemCallback = func;
    86     } else {
     94    }
     95    else
     96    {
    8797        memProblemCallback = memProblemCallbackDefault;
    8898    }
     
    144154    psMemFreeCallback old = memAllocateCallback;
    145155
    146     if (func != NULL) {
     156    if (func != NULL)
     157    {
    147158        memAllocateCallback =  func;
    148     } else {
     159    }
     160    else
     161    {
    149162        memAllocateCallback = memAllocateCallbackDefault;
    150163    }
     
    157170    psMemFreeCallback old = memFreeCallback;
    158171
    159     if (func != NULL) {
     172    if (func != NULL)
     173    {
    160174        memFreeCallback = func;
    161     } else {
     175    }
     176    else
     177    {
    162178        memFreeCallback = memFreeCallbackDefault;
    163179    }
     
    188204    // we shouldn't call such things as p_psAlloc/p_psFree here.
    189205
    190     if (m == NULL) {
     206    if (m == NULL)
     207    {
    191208        psError(funcName,"Memory Corruption: NULL memory block found.");
    192209        return(1);
    193210    }
    194211
    195     if (!ALIGNED(m)) {
     212    if (!ALIGNED(m))
     213    {
    196214        psError(funcName, "psMemCheckCorruption: non-aligned memory block");
    197215        return(1);
    198216    }
    199217
    200     if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
     218    if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC)
     219    {
    201220        psError(funcName, "psMemCheckCorruption: memory block %ld is corrupted", m->id);
    202221        return(1);
     
    213232    pthread_mutex_lock(&memBlockListMutex);
    214233
    215     for (psMemBlock* iter=lastMemBlockAllocated; iter != NULL; iter=iter->nextBlock) {
    216         if (checkMemBlock(iter, __func__)) {
     234    for (psMemBlock* iter=lastMemBlockAllocated; iter != NULL; iter=iter->nextBlock)
     235    {
     236        if (checkMemBlock(iter, __func__))
     237        {
    217238            nbad++;
    218239
    219240            memProblemCallback(iter, __func__, __LINE__);
    220241
    221             if (abort_on_error) {
     242            if (abort_on_error)
     243            {
    222244                // release the lock on the memblock list
    223245                pthread_mutex_unlock(&memBlockListMutex);
     
    237259    psMemBlock *ptr = malloc(sizeof(psMemBlock) + size);
    238260
    239     if (ptr == NULL) {
     261    if (ptr == NULL)
     262    {
    240263        ptr = memExhaustedCallback(size);
    241         if (ptr == NULL) {
     264        if (ptr == NULL)
     265        {
    242266            psAbort(__func__, "Failed to allocate %ld bytes at %s:%d",
    243267                    size, file, lineno);
     
    258282    ptr->previousBlock = NULL;
    259283    ptr->nextBlock = lastMemBlockAllocated;
    260     if (ptr->nextBlock != NULL) {
     284    if (ptr->nextBlock != NULL)
     285    {
    261286        ptr->nextBlock->previousBlock = ptr;
    262287    }
     
    266291
    267292    //  Did the user ask to be informed about this allocation?
    268     if (ptr->id == p_psMemAllocateID) {
     293    if (ptr->id == p_psMemAllocateID)
     294    {
    269295        p_psMemAllocateID += memAllocateCallback(ptr);
    270296    }
     
    276302void *p_psRealloc(void *vptr, size_t size, const char *file, int lineno)
    277303{
    278     if (vptr == NULL) {
     304    if (vptr == NULL)
     305    {
    279306        return p_psAlloc(size, file, lineno);
    280     } else {
     307    }
     308    else
     309    {
    281310        psMemBlock *ptr = ((psMemBlock *)vptr) - 1;
    282311
     
    286315
    287316        // the block location may have changed, so fix the linked list addresses.
    288         if (ptr->nextBlock != NULL) {
     317        if (ptr->nextBlock != NULL)
     318        {
    289319            ptr->nextBlock->previousBlock = ptr;
    290320        }
    291         if (ptr->previousBlock != NULL) {
     321        if (ptr->previousBlock != NULL)
     322        {
    292323            ptr->previousBlock->nextBlock = ptr;
    293324        }
     
    301332void p_psFree(void *vptr, const char *file, int lineno)
    302333{
    303     if (vptr == NULL) {
     334    if (vptr == NULL)
     335    {
    304336        return;
    305337    }
     
    308340
    309341    // Did the user ask to be informed about this deallocation?
    310     if (ptr->id == p_psMemFreeID) {
     342    if (ptr->id == p_psMemFreeID)
     343    {
    311344        p_psMemFreeID += memFreeCallback(ptr);
    312345    }
    313346
    314     if (checkMemBlock(ptr, "psFree") != 0) {
     347    if (checkMemBlock(ptr, "psFree") != 0)
     348    {
    315349        memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it
    316     } else {
    317         if (ptr->refCounter > 1) {
     350    }
     351    else
     352    {
     353        if (ptr->refCounter > 1)
     354        {
    318355            psError(__func__,"The buffer being freed is referenced elsewhere. "
    319356                    "Buffer's reference count was decremented instead.");
    320357            ptr->refCounter--;
    321358            memProblemCallback(ptr, file, lineno);
    322         } else {
     359        }
     360        else
     361        {
    323362
    324363            // cut the memBlock out of the memBlock list
    325364            pthread_mutex_lock(&memBlockListMutex);
    326             if (ptr->nextBlock != NULL) {
     365            if (ptr->nextBlock != NULL)
     366            {
    327367                ptr->nextBlock->previousBlock = ptr->previousBlock;
    328368            }
    329             if (ptr->previousBlock != NULL) {
     369            if (ptr->previousBlock != NULL)
     370            {
    330371                ptr->previousBlock->nextBlock = ptr->nextBlock;
    331372            }
    332             if (lastMemBlockAllocated == ptr) {
     373            if (lastMemBlockAllocated == ptr)
     374            {
    333375                lastMemBlockAllocated = ptr->nextBlock;
    334376            }
     
    356398    for (psMemBlock* iter = lastMemBlockAllocated; iter != NULL; iter=iter->nextBlock)
    357399    {
    358         if ( (iter->refCounter > 0) && (iter->id >= id0) ) {
     400        if ( (iter->refCounter > 0) && (iter->id >= id0) )
     401        {
    359402            nleak++;
    360403
    361             if (fd != NULL) {
    362                 if (nleak == 1) {
     404            if (fd != NULL)
     405            {
     406                if (nleak == 1)
     407                {
    363408                    fprintf(fd, "   %20s:line ID\n", "file");
    364409                }
     
    384429    for (psMemBlock* iter = lastMemBlockAllocated; iter != NULL; iter=iter->nextBlock)
    385430    {
    386         if ( (iter->refCounter > 0) && (iter->id >= id0) ) {
     431        if ( (iter->refCounter > 0) && (iter->id >= id0) )
     432        {
    387433            (*arr)[j++] = iter;
    388             if (j == nleak) { // found them all
     434            if (j == nleak)
     435            { // found them all
    389436                break;
    390437            }
  • trunk/psLib/src/sysUtils/psMemory.c

    r468 r469  
    88 *  @author Robert Lupton, Princeton University
    99 *
    10  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-04-20 02:52:48 $
     10 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-04-20 02:58:46 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4848    psMemExhaustedCallback old = memExhaustedCallback;
    4949
    50     if (func != NULL) {
     50    if (func != NULL)
     51    {
    5152        memExhaustedCallback = func;
    52     } else {
     53    }
     54    else
     55    {
    5356        memExhaustedCallback = memExhaustedCallbackDefault;
    5457    }
     
    6265    checkMemBlock(ptr, __func__);
    6366
    64     if (ptr->refCounter <= 0) {
     67    if (ptr->refCounter <= 0)
     68    {
    6569        psError(__func__,
    6670                "Block %ld allocated at %s:%d freed more than once at %s:%d\n",
    6771                ptr->id, ptr->file, ptr->lineno, file, lineno);
    68     } else if (ptr->refCounter > 1) {
     72    }
     73    else if (ptr->refCounter > 1)
     74    {
    6975        psError(__func__,
    7076                "Block %ld allocated at %s:%d freed while still referenced at %s:%d\n",
     
    7278    }
    7379
    74     if (lineno > 0) {
     80    if (lineno > 0)
     81    {
    7582        psAbort(__func__, "Detected a problem in the memory system at %s:%d", file, lineno);
    7683    }
     
    8289    psMemProblemCallback old = memProblemCallback;
    8390
    84     if (func != NULL) {
     91    if (func != NULL)
     92    {
    8593        memProblemCallback = func;
    86     } else {
     94    }
     95    else
     96    {
    8797        memProblemCallback = memProblemCallbackDefault;
    8898    }
     
    144154    psMemFreeCallback old = memAllocateCallback;
    145155
    146     if (func != NULL) {
     156    if (func != NULL)
     157    {
    147158        memAllocateCallback =  func;
    148     } else {
     159    }
     160    else
     161    {
    149162        memAllocateCallback = memAllocateCallbackDefault;
    150163    }
     
    157170    psMemFreeCallback old = memFreeCallback;
    158171
    159     if (func != NULL) {
     172    if (func != NULL)
     173    {
    160174        memFreeCallback = func;
    161     } else {
     175    }
     176    else
     177    {
    162178        memFreeCallback = memFreeCallbackDefault;
    163179    }
     
    188204    // we shouldn't call such things as p_psAlloc/p_psFree here.
    189205
    190     if (m == NULL) {
     206    if (m == NULL)
     207    {
    191208        psError(funcName,"Memory Corruption: NULL memory block found.");
    192209        return(1);
    193210    }
    194211
    195     if (!ALIGNED(m)) {
     212    if (!ALIGNED(m))
     213    {
    196214        psError(funcName, "psMemCheckCorruption: non-aligned memory block");
    197215        return(1);
    198216    }
    199217
    200     if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
     218    if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC)
     219    {
    201220        psError(funcName, "psMemCheckCorruption: memory block %ld is corrupted", m->id);
    202221        return(1);
     
    213232    pthread_mutex_lock(&memBlockListMutex);
    214233
    215     for (psMemBlock* iter=lastMemBlockAllocated; iter != NULL; iter=iter->nextBlock) {
    216         if (checkMemBlock(iter, __func__)) {
     234    for (psMemBlock* iter=lastMemBlockAllocated; iter != NULL; iter=iter->nextBlock)
     235    {
     236        if (checkMemBlock(iter, __func__))
     237        {
    217238            nbad++;
    218239
    219240            memProblemCallback(iter, __func__, __LINE__);
    220241
    221             if (abort_on_error) {
     242            if (abort_on_error)
     243            {
    222244                // release the lock on the memblock list
    223245                pthread_mutex_unlock(&memBlockListMutex);
     
    237259    psMemBlock *ptr = malloc(sizeof(psMemBlock) + size);
    238260
    239     if (ptr == NULL) {
     261    if (ptr == NULL)
     262    {
    240263        ptr = memExhaustedCallback(size);
    241         if (ptr == NULL) {
     264        if (ptr == NULL)
     265        {
    242266            psAbort(__func__, "Failed to allocate %ld bytes at %s:%d",
    243267                    size, file, lineno);
     
    258282    ptr->previousBlock = NULL;
    259283    ptr->nextBlock = lastMemBlockAllocated;
    260     if (ptr->nextBlock != NULL) {
     284    if (ptr->nextBlock != NULL)
     285    {
    261286        ptr->nextBlock->previousBlock = ptr;
    262287    }
     
    266291
    267292    //  Did the user ask to be informed about this allocation?
    268     if (ptr->id == p_psMemAllocateID) {
     293    if (ptr->id == p_psMemAllocateID)
     294    {
    269295        p_psMemAllocateID += memAllocateCallback(ptr);
    270296    }
     
    276302void *p_psRealloc(void *vptr, size_t size, const char *file, int lineno)
    277303{
    278     if (vptr == NULL) {
     304    if (vptr == NULL)
     305    {
    279306        return p_psAlloc(size, file, lineno);
    280     } else {
     307    }
     308    else
     309    {
    281310        psMemBlock *ptr = ((psMemBlock *)vptr) - 1;
    282311
     
    286315
    287316        // the block location may have changed, so fix the linked list addresses.
    288         if (ptr->nextBlock != NULL) {
     317        if (ptr->nextBlock != NULL)
     318        {
    289319            ptr->nextBlock->previousBlock = ptr;
    290320        }
    291         if (ptr->previousBlock != NULL) {
     321        if (ptr->previousBlock != NULL)
     322        {
    292323            ptr->previousBlock->nextBlock = ptr;
    293324        }
     
    301332void p_psFree(void *vptr, const char *file, int lineno)
    302333{
    303     if (vptr == NULL) {
     334    if (vptr == NULL)
     335    {
    304336        return;
    305337    }
     
    308340
    309341    // Did the user ask to be informed about this deallocation?
    310     if (ptr->id == p_psMemFreeID) {
     342    if (ptr->id == p_psMemFreeID)
     343    {
    311344        p_psMemFreeID += memFreeCallback(ptr);
    312345    }
    313346
    314     if (checkMemBlock(ptr, "psFree") != 0) {
     347    if (checkMemBlock(ptr, "psFree") != 0)
     348    {
    315349        memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it
    316     } else {
    317         if (ptr->refCounter > 1) {
     350    }
     351    else
     352    {
     353        if (ptr->refCounter > 1)
     354        {
    318355            psError(__func__,"The buffer being freed is referenced elsewhere. "
    319356                    "Buffer's reference count was decremented instead.");
    320357            ptr->refCounter--;
    321358            memProblemCallback(ptr, file, lineno);
    322         } else {
     359        }
     360        else
     361        {
    323362
    324363            // cut the memBlock out of the memBlock list
    325364            pthread_mutex_lock(&memBlockListMutex);
    326             if (ptr->nextBlock != NULL) {
     365            if (ptr->nextBlock != NULL)
     366            {
    327367                ptr->nextBlock->previousBlock = ptr->previousBlock;
    328368            }
    329             if (ptr->previousBlock != NULL) {
     369            if (ptr->previousBlock != NULL)
     370            {
    330371                ptr->previousBlock->nextBlock = ptr->nextBlock;
    331372            }
    332             if (lastMemBlockAllocated == ptr) {
     373            if (lastMemBlockAllocated == ptr)
     374            {
    333375                lastMemBlockAllocated = ptr->nextBlock;
    334376            }
     
    356398    for (psMemBlock* iter = lastMemBlockAllocated; iter != NULL; iter=iter->nextBlock)
    357399    {
    358         if ( (iter->refCounter > 0) && (iter->id >= id0) ) {
     400        if ( (iter->refCounter > 0) && (iter->id >= id0) )
     401        {
    359402            nleak++;
    360403
    361             if (fd != NULL) {
    362                 if (nleak == 1) {
     404            if (fd != NULL)
     405            {
     406                if (nleak == 1)
     407                {
    363408                    fprintf(fd, "   %20s:line ID\n", "file");
    364409                }
     
    384429    for (psMemBlock* iter = lastMemBlockAllocated; iter != NULL; iter=iter->nextBlock)
    385430    {
    386         if ( (iter->refCounter > 0) && (iter->id >= id0) ) {
     431        if ( (iter->refCounter > 0) && (iter->id >= id0) )
     432        {
    387433            (*arr)[j++] = iter;
    388             if (j == nleak) { // found them all
     434            if (j == nleak)
     435            { // found them all
    389436                break;
    390437            }
Note: See TracChangeset for help on using the changeset viewer.