IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 20, 2004, 6:12:37 PM (22 years ago)
Author:
eugene
Message:

substantial API changes based on change to PSLib SDRS

Location:
trunk/archive/pslib/src/Utils
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/src/Utils/Makefile

    r707 r753  
    22CFLAGS = -Wall -g -I$(PSLIB_DIR)/include -I$(FFTW_DIR)/include
    33DYLIB = dylib
    4 DYLIB_LDFLAGS = "-undefined suppress -flat_namespace -dynamiclib";
     4DYLIB_LDFLAGS = -undefined suppress -flat_namespace -dynamiclib -shared
    55
    66PSLIB_DIR = ../..
  • trunk/archive/pslib/src/Utils/dlist.c

    r707 r753  
    317317    psDlistElem *ptr = dlist->head;
    318318    for (int i = 0, n = dlist->n; i < n; i++) {
    319         arr->arr.arr_v[i] = ptr->data;
    320 
     319        arr->data.V[i] = ptr->data;
    321320        ptr->data = NULL;
    322321        ptr = ptr->next;
     
    339338    for (int i = 0, n = arr->n; i < n; i++) {
    340339        psDlistAppend(list,
    341                       psMemDecrRefCounter(arr->arr.arr_v[i])); // it\'s already Incr
    342         arr->arr.arr_v[i] = NULL;
     340                      psMemDecrRefCounter(arr->data.V[i])); // it\'s already Incr
     341        arr->data.V[i] = NULL;
    343342    }
    344343
  • trunk/archive/pslib/src/Utils/error.c

    r707 r753  
    7676int psError(const char *name,           // category of code that caused the error
    7777            psErrorCode code,           // code of error (equivalent to errno)
    78             psErrorStatus status,       // is this a new error?
     78            int new,                    // is this a new error?
    7979            const char *fmt, ...)       // format and possible extra arguments
    8080{
    81     if (code == PS_ERR_NONE || status == PS_NEW_ERROR) { // free old error stack
     81    if (code == PS_ERR_NONE || new) { // free old error stack
    8282        errStack *eptr = errorStack;
    8383
     
    9999       
    100100        va_start(ap, fmt);
    101         p_psLogVMsg(name, PS_LOG_ERROR, fmt, ap);
     101        psLogMsgV(name, PS_LOG_ERROR, fmt, ap);
    102102        va_end(ap);
    103103    }
     
    210210    }
    211211
    212     psErrorVStackPrint(fd, fmt, ap);
     212    psErrorStackPrintV(fd, fmt, ap);
    213213
    214214    if (fmt != NULL) {
     
    217217}
    218218
    219 void psErrorVStackPrint(FILE *fd,       // write to this file descriptor
     219void psErrorStackPrintV(FILE *fd,       // write to this file descriptor
    220220                        const char *fmt,// format for any header information; may be NULL
    221221                        va_list ap)     // arguments for format
  • trunk/archive/pslib/src/Utils/logmsg.c

    r707 r753  
    110110#endif
    111111
    112 void p_psLogVMsg(const char *name, int level, const char *fmt, va_list ap)
     112void psLogMsgV(const char *name, int level, const char *fmt, va_list ap)
    113113{
    114114    static int first = 1;
     
    224224    va_start(ap, fmt);
    225225
    226     p_psLogVMsg(name, level, fmt, ap);
     226    psLogVMsg(name, level, fmt, ap);
    227227    va_end(ap);
    228228}
  • trunk/archive/pslib/src/Utils/memory.c

    r687 r753  
    4848 * First the I-can't-get-the-memory callback
    4949 */
    50 static void *memExhaustedCB0(size_t size)
     50static void *memExhaustedCallback0(size_t size)
    5151{
    5252    return NULL;
    5353}
    54 static psMemExhaustedCB memExhaustedCB = memExhaustedCB0;
    55 
    56 psMemExhaustedCB psMemExhaustedCBSet(psMemExhaustedCB func)
    57 {
    58     psMemExhaustedCB old = memExhaustedCB;
    59 
    60     memExhaustedCB = (func != NULL) ? func : memExhaustedCB0;
     54static psMemExhaustedCallback memExhaustedCallback = memExhaustedCallback0;
     55
     56psMemExhaustedCallback psMemExhaustedCallbackSet(psMemExhaustedCallback func)
     57{
     58    psMemExhaustedCallback old = memExhaustedCallback;
     59
     60    memExhaustedCallback = (func != NULL) ? func : memExhaustedCallback0;
    6161
    6262    return old;
     
    6565 * then the I-have-detected-a-problem callback
    6666 */
    67 static void memProblemCB0(const psMemBlock *ptr,
     67static void memProblemCallback0(const psMemBlock *ptr,
    6868                          const char *file, int lineno)
    6969{
     
    7676        fprintf(stderr, "\n");
    7777    } else if (ptr->refCounter <= 0) {
    78         psError(__func__, PS_ERR_BADFREE, PS_NEW_ERROR,
     78        psError(__func__, PS_ERR_BADFREE, 1,
    7979                "Block %ld allocated at %s:%d freed more than once at %s:%d\n",
    8080                ptr->id, ptr->file, ptr->lineno, file, lineno);
    8181    } else if (ptr->refCounter > 1) {
    82         psError(__func__,  PS_ERR_BADFREE, PS_NEW_ERROR,
     82        psError(__func__,  PS_ERR_BADFREE, 1,
    8383                "Block %ld allocated at %s:%d freed while still referenced at %s:%d\n",
    8484                ptr->id, ptr->file, ptr->lineno, file, lineno);
     
    8989    }
    9090}
    91 static psMemProblemCB memProblemCB = memProblemCB0;
    92 
    93 psMemProblemCB psMemProblemCBSet(psMemProblemCB func)
    94 {
    95     psMemProblemCB old = memProblemCB;
    96 
    97     memProblemCB = (func != NULL) ? func : memProblemCB0;
     91static psMemProblemCallback memProblemCallback = memProblemCallback0;
     92
     93psMemProblemCallback psMemProblemCallbackSet(psMemProblemCallback func)
     94{
     95    psMemProblemCallback old = memProblemCallback;
     96
     97    memProblemCallback = (func != NULL) ? func : memProblemCallback0;
    9898
    9999    return old;
     
    129129 * isn't resignalled)
    130130 */
    131 static long memAllocateCB0(const psMemBlock *ptr)
     131static long memAllocateCallback0(const psMemBlock *ptr)
    132132{
    133133    static int incr = 0;                // "p_psMemAllocateID += incr"
     
    138138}
    139139
    140 static long memFreeCB0(const psMemBlock *ptr)
     140static long memFreeCallback0(const psMemBlock *ptr)
    141141{
    142142    static int incr = 0;                // "p_psMemFreeID += incr"
     
    150150 * The default callbacks, and the routines to change them
    151151 */
    152 static psMemAllocateCB memAllocateCB = memAllocateCB0;
    153 static psMemFreeCB memFreeCB = memFreeCB0;
    154 
    155 psMemAllocateCB psMemAllocateCBSet(psMemAllocateCB func)
    156 {
    157     psMemAllocateCB old = memAllocateCB;
    158 
    159     memAllocateCB = (func != NULL) ? func : memAllocateCB0;
    160 
    161     return old;
    162 }
    163 
    164 psMemFreeCB psMemFreeCBSet(psMemFreeCB func)
    165 {
    166     psMemFreeCB old = memFreeCB;
    167 
    168     memFreeCB = (func != NULL) ? func : memFreeCB0;
     152static psMemAllocateCallback memAllocateCallback = memAllocateCallback0;
     153static psMemFreeCallback memFreeCallback = memFreeCallback0;
     154
     155psMemAllocateCallback psMemAllocateCallbackSet(psMemAllocateCallback func)
     156{
     157    psMemAllocateCallback old = memAllocateCallback;
     158
     159    memAllocateCallback = (func != NULL) ? func : memAllocateCallback0;
     160
     161    return old;
     162}
     163
     164psMemFreeCallback psMemFreeCallbackSet(psMemFreeCallback func)
     165{
     166    psMemFreeCallback old = memFreeCallback;
     167
     168    memFreeCallback = (func != NULL) ? func : memFreeCallback0;
    169169
    170170    return old;
     
    194194    if (m == NULL) {
    195195        if (!quiet) {
    196             psError(__func__,  PS_ERR_MEMORY_CORRUPTION, PS_NEW_ERROR,
     196            psError(__func__,  PS_ERR_MEMORY_CORRUPTION, 1,
    197197                    "psMemCheckCorruption: NULL memory block\n");
    198198        }
     
    202202    if (!ALIGNED(m)) {
    203203        if (!quiet) {
    204             psError(__func__,  PS_ERR_MEMORY_CORRUPTION, PS_NEW_ERROR,
     204            psError(__func__,  PS_ERR_MEMORY_CORRUPTION, 1,
    205205                    "psMemCheckCorruption: non-aligned memory block\n");
    206206        }
     
    210210    if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
    211211        if (!quiet) {
    212             psError(__func__, PS_ERR_MEMORY_CORRUPTION, PS_NEW_ERROR,
     212            psError(__func__, PS_ERR_MEMORY_CORRUPTION, 1,
    213213                    "psMemCheckCorruption: memory block %ld is corrupted\n", m->id);
    214214        }
     
    232232                nbad++;
    233233
    234                 memProblemCB(memBlocks[i], "(psMemCheckCorruption)", 0);
     234                memProblemCallback(memBlocks[i], "(psMemCheckCorruption)", 0);
    235235               
    236236                if (abort_on_error) {
     
    251251
    252252    if (ptr == NULL) {
    253         ptr = memExhaustedCB(size);
     253        ptr = memExhaustedCallback(size);
    254254        if (ptr == NULL) {
    255255            psAbort(__func__, "Failed to allocate %ld bytes at %s:%d",
     
    270270   
    271271    if (ptr->id == p_psMemAllocateID && p_psMemAllocateID > 0) {
    272         p_psMemAllocateID += memAllocateCB(ptr);       
     272        p_psMemAllocateID += memAllocateCallback(ptr); 
    273273    }
    274274    /*
     
    310310     */
    311311    if (ptr->id == p_psMemFreeID && p_psMemFreeID > 0) {
    312         p_psMemFreeID += memFreeCB(ptr);       
     312        p_psMemFreeID += memFreeCallback(ptr); 
    313313    }
    314314
    315315    if (bad_memblock(ptr, 0)) {
    316         memProblemCB(ptr, file, lineno); // we may not own this block; don't free it
     316        memProblemCallback(ptr, file, lineno); // we may not own this block; don't free it
    317317    } else {
    318318        if (ptr->refCounter != 1) {
    319             memProblemCB(ptr, file, lineno);
     319            memProblemCallback(ptr, file, lineno);
    320320        }
    321321        ptr->refCounter--;
     
    396396
    397397    if (bad_memblock(ptr, 0)) {
    398         memProblemCB(ptr, "(psMemGetRefCounter)", -1);
     398        memProblemCallback(ptr, "(psMemGetRefCounter)", -1);
    399399    }
    400400
     
    411411
    412412    if (bad_memblock(ptr, 0)) {
    413         memProblemCB(ptr, "(psMemIncrRefCounter)", -1);
     413        memProblemCallback(ptr, "(psMemIncrRefCounter)", -1);
    414414    }
    415415
     
    428428
    429429    if (bad_memblock(ptr, 0)) {
    430         memProblemCB(ptr, "(psMemDecrRefCounter)", -1);
     430        memProblemCallback(ptr, "(psMemDecrRefCounter)", -1);
    431431    }
    432432
  • trunk/archive/pslib/src/Utils/misc.c

    r707 r753  
    2929
    3030    va_start(ap, fmt);
    31     p_psLogVMsg(name, PS_LOG_ABORT, fmt, ap);
     31    psLogMsgV(name, PS_LOG_ABORT, fmt, ap);
    3232    va_end(ap);
    3333   
  • trunk/archive/pslib/src/Utils/vector.c

    r709 r753  
    1616
    1717   *(int *)&vec->n = *(int *)&vec->nalloc = nalloc;
    18    vec->arr.arr_v = psAlloc(nalloc*sizeof(void **));
     18   vec->data.V = psAlloc(nalloc*sizeof(void **));
    1919
    2020   return vec;
     
    3434
    3535   if (elemFree != NULL && vec->nalloc > 0) {
    36       assert (vec->arr.arr != NULL);    /* choose any member of the union */
     36      assert (vec->data.V != NULL);     /* choose any member of the union */
    3737      const int n = vec->nalloc;
    3838      for (int i = 0; i < n; i++) {
    39          elemFree(vec->arr.arr_v[i]);
     39         elemFree(vec->data.V[i]);
    4040      }
    4141   }
    4242
    43    psFree(vec->arr.arr_v);
     43   psFree(vec->data.V);
    4444   psFree(vec);
    4545}
Note: See TracChangeset for help on using the changeset viewer.