IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 19, 2004, 9:14:22 AM (22 years ago)
Author:
rhl
Message:

Moved test code to tst_*.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/src/Utils/array.c

    r164 r265  
    3636    my_psVoidPtrArrayFree(arr);
    3737}
    38 
    39 /*****************************************************************************/
    40 #if 0                                   // testing
    41 
    42 typedef struct {
    43     int x, y;
    44 } psXY;
    45 
    46 psXY *psXYAlloc(void)
    47 {
    48     return psAlloc(sizeof(psXY));
    49 }
    50 
    51 void psXYFree(psXY *xy)
    52 {
    53     psFree(xy);
    54 }
    55 
    56 PS_DECLARE_ARRAY_TYPE(psXY);
    57 PS_CREATE_ARRAY_TYPE(psXY);
    58 
    59 PS_DECLARE_ARRAY_PTR_TYPE(psXY);
    60 PS_CREATE_ARRAY_PTR_TYPE(psXY);
    61 
    62 int main(void)
    63 {
    64     psXYArray *t = psXYArrayAlloc(10, 15);
    65     psXYPtrArray *pt = psXYPtrArrayAlloc(10, 10);
    66 
    67     for (int i = 0; i < t->n; i++) {
    68         t->arr[i].x = i;
    69         pt->arr[i]->y = 10*i;
    70     }
    71 
    72     t = psXYArrayRealloc(t, 5);
    73     t = psXYArrayRealloc(t, 8);
    74 
    75     for (int i = 0; i < t->n; i++) {
    76         printf("%d %d  ", t->arr[i].x, pt->arr[i]->y);
    77     }
    78     printf("\n");
    79    
    80     psXYArrayFree(t);
    81 
    82     psXY *xy = psMemDecrRefCounter(pt->arr[0]);
    83     pt->arr[0] = NULL;
    84     psXYFree(xy);   
    85    
    86     psXYPtrArrayFree(pt);
    87 
    88     psMemCheckLeaks(0, NULL, stderr);
    89 
    90     return 0;
    91 }
    92 #endif
Note: See TracChangeset for help on using the changeset viewer.