Changeset 69


Ignore:
Timestamp:
08/30/11 12:23:52 (21 months ago)
Author:
pouillon
Message:

Added copy function to quantum numbers

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/pspio_qn.c

    r65 r69  
    2525 
    2626int pspio_qn_alloc(pspio_qn_t *qn) { 
    27   qn = (pspio_qn_t *)malloc(sizeof(pspio_qn_t)); 
     27  if ( qn != NULL ) { 
     28    return PSPIO_ERROR; 
     29  } 
     30  qn = (pspio_qn_t *)malloc(sizeof(qn)); 
    2831  if ( qn == NULL ) { 
    2932    return PSPIO_ERROR; 
     
    3336  qn->l = 0; 
    3437  qn->j = 0.0; 
     38 
     39  return PSPIO_SUCCESS; 
     40} 
     41 
     42 
     43int pspio_qn_copy(pspio_qn_t *dst, pspio_qn_t *src) { 
     44  if ( (src == NULL) || (dst != NULL) ) { 
     45    return PSPIO_ERROR; 
     46  } 
     47 
     48  dst = (pspio_qn_t *)malloc(sizeof(dst)); 
     49  if ( dst == NULL ) { 
     50    return PSPIO_ERROR; 
     51  } 
     52  dst->n = src->n; 
     53  dst->l = src->l; 
     54  dst->j = src->j; 
    3555 
    3656  return PSPIO_SUCCESS; 
  • trunk/src/pspio_qn.h

    r57 r69  
    4949 
    5050/** 
    51  * Allocates and presets an quantum number structure. 
     51 * Allocates and presets a quantum number structure. 
    5252 * @param[out] qn: quantum number structure pointer to allocate 
    5353 * @return error code 
    5454 */ 
    5555int pspio_qn_alloc(pspio_qn_t *qn); 
     56 
     57 
     58/** 
     59 * Duplicates a quantum number structure. 
     60 * @param[out] dst: destination quantum number structure pointer 
     61 * @param[out] src: source quantum number structure pointer  
     62 * @return error code 
     63 */ 
     64int pspio_qn_copy(pspio_qn_t *dst, pspio_qn_t *src); 
    5665 
    5766 
Note: See TracChangeset for help on using the changeset viewer.