IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 948


Ignore:
Timestamp:
Jun 9, 2004, 9:51:08 AM (22 years ago)
Author:
desonia
Message:

Fixed memory leaks in the test code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/collections/tst_psList.c

    r946 r948  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-09 19:27:09 $
     8 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-09 19:51:08 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    108108    psListFree(list,PS_FREE);
    109109
    110     if (psMemCheckLeaks(currentId,NULL,NULL) != 0) {
     110    if (psMemCheckLeaks(currentId,NULL,stderr) != 0) {
    111111        psError(__func__,"Memory Leaks Detected");
    112112        return 64;
     
    121121    int currentId = psMemGetId();
    122122    psList* list = NULL;
    123     int* data;
     123    int* data = NULL;
    124124
    125125    psLogMsg(__func__,PS_LOG_INFO,"psListAdd shall add an element to list");
     
    135135    */
    136136
     137    data = psAlloc(sizeof(int));
     138    *data = 1;
     139
    137140    //  1. list is NULL (error)
    138141    list = psListAdd(NULL,data,PS_LIST_HEAD);
     
    144147
    145148    //  2. data is NULL (error, list should not grow)
    146     data = psAlloc(sizeof(int));
    147     *data = 1;
    148149    list = psListAlloc(data);
     150    psFree(data);
    149151    if (list->size != 1) {
    150152        psError(__func__,"psListAlloc didn't create a list properly.");
     
    163165    *data = 2;
    164166    list = psListAdd(list,data,PS_LIST_HEAD);
    165 
     167    psFree(data);
    166168    // verify that the size incremented
    167169    if (list->size != 2) {
     
    179181    *data = 3;
    180182    list = psListAdd(list,data,PS_LIST_TAIL);
    181 
     183    psFree(data);
    182184    // verify that the size incremented
    183185    if (list->size != 3) {
     
    202204    data = psAlloc(sizeof(int));
    203205    *data = 4;
    204 
    205206    psLogMsg(__func__,PS_LOG_INFO,"Following should warn with invalid insert location");
    206207    list = psListAdd(list,data,-10);
     208    psFree(data);
    207209    // verify that the size incremented
    208210    if (list->size != 4 || *(int*)list->head->data != 4) {
     
    216218    *data = 5;
    217219    list = psListAdd(list,data,1);
     220    psFree(data);
    218221    // verify that the size incremented
    219222    if (list->size != 5 || *(int*)list->head->next->data != 5) {
     
    226229    *data = 6;
    227230    list = psListAdd(list,data,4);
     231    psFree(data);
    228232    // verify that the size incremented
    229233    if (list->size != 6  || *(int *)list->head->next->next->next->next->data != 6) {
     
    236240    *data = 7;
    237241    list = psListAdd(list,data,2);
     242    psFree(data);
    238243    // verify that the size incremented
    239244    if (list->size != 7  || *(int *)list->head->next->next->data != 7) {
     
    247252    psLogMsg(__func__,PS_LOG_INFO,"Following should be a warning.");
    248253    list = psListAdd(list,data,9);
     254    psFree(data);
    249255    // verify that the size incremented
    250256    if (list->size != 8) {
     
    256262    psListFree(list, PS_FREE);
    257263
    258     if (psMemCheckLeaks(currentId,NULL,NULL) != 0) {
     264    if (psMemCheckLeaks(currentId,NULL,stderr) != 0) {
    259265        psError(__func__,"Memory Leaks Detected");
    260266        return 64;
     
    384390    psListFree(list,PS_FREE);
    385391
    386     if (psMemCheckLeaks(currentId,NULL,NULL) != 0) {
     392    if (psMemCheckLeaks(currentId,NULL,stderr) != 0) {
    387393        psError(__func__,"Memory Leaks Detected");
    388394        return 64;
     
    624630    psListFree(list,PS_FREE);
    625631
    626     if (psMemCheckLeaks(currentId,NULL,NULL) != 0) {
     632    if (psMemCheckLeaks(currentId,NULL,stderr) != 0) {
    627633        psError(__func__,"Memory Leaks Detected");
    628634        return 64;
     
    686692    psListFree(list,PS_FREE);
    687693
    688     if (psMemCheckLeaks(currentId,NULL,NULL) != 0) {
     694    if (psMemCheckLeaks(currentId,NULL,stderr) != 0) {
    689695        psError(__func__,"Memory Leaks Detected");
    690696        return 64;
     
    703709    }
    704710
    705     list = psVectorToDlist(vec);
     711    list = psVectorToList(vec);
    706712
    707713    if (vec->n != 15 || list->size != 15) {
     
    738744    }
    739745
    740     list = psVectorToDlist(NULL);
     746    list = psVectorToList(NULL);
    741747    if (list != NULL) {
    742         psError(__func__,"psVectorToDlist didn't return NULL when given NULL");
     748        psError(__func__,"psVectorToList didn't return NULL when given NULL");
    743749        return 1;
    744750    }
     
    747753    vec = psVectorAlloc(1,PS_TYPE_PTR);
    748754    vec->n = 0;
    749     list = psVectorToDlist(vec);
     755    list = psVectorToList(vec);
    750756    if (list == NULL) {
    751         psError(__func__,"psVectorToDlist didn't create an empty list from an "
     757        psError(__func__,"psVectorToList didn't create an empty list from an "
    752758                "empty vector.");
    753759        return 1;
     
    759765    vec = psListToVector(list);
    760766    if (vec == NULL) {
    761         psError(__func__,"psVectorToDlist didn't create an empty vector from an "
     767        psError(__func__,"psVectorToList didn't create an empty vector from an "
    762768                "empty list.");
    763769        return 1;
     
    766772    psListFree(list,PS_FREE);
    767773
    768     if (psMemCheckLeaks(currentId,NULL,NULL) != 0) {
     774    if (psMemCheckLeaks(currentId,NULL,stderr) != 0) {
    769775        psError(__func__,"Memory Leaks Detected");
    770776        return 64;
     
    807813        *data = lcv;
    808814        list = psListAdd(list,data,PS_LIST_TAIL);
    809         psMemDecrRefCounter(data);
     815        psFree(data);
    810816    }
    811817
     
    900906    }
    901907
    902     if (psMemCheckLeaks(currentId,NULL,NULL) != 0) {
     908    psListFree(list,PS_FREE);
     909
     910    if (psMemCheckLeaks(currentId,NULL,stderr) != 0) {
    903911        psError(__func__,"Memory Leaks Detected");
    904912        return 64;
Note: See TracChangeset for help on using the changeset viewer.