예제 #1
0
void *spice_malloc_n_m(size_t n_blocks, size_t n_block_bytes, size_t extra_size)
{
    size_t size1, size2;
    if (SIZE_OVERFLOWS (n_blocks, n_block_bytes)) {
        MALLOC_ERROR("spice_malloc_n: overflow allocating %lu*%lu + %lubytes",
                     (unsigned long)n_blocks, (unsigned long)n_block_bytes, (unsigned long)extra_size);
    }
    size1 = n_blocks * n_block_bytes;
    size2 = size1 + extra_size;
    if (size2 < size1) {
        MALLOC_ERROR("spice_malloc_n: overflow allocating %lu*%lu + %lubytes",
                     (unsigned long)n_blocks, (unsigned long)n_block_bytes, (unsigned long)extra_size);
    }
    return spice_malloc(size2);
}
예제 #2
0
void *spice_realloc_n(void *mem, size_t n_blocks, size_t n_block_bytes)
{
    if (SIZE_OVERFLOWS (n_blocks, n_block_bytes)) {
        MALLOC_ERROR("spice_realloc_n: overflow allocating %lu*%lu bytes",
                     (unsigned long)n_blocks, (unsigned long)n_block_bytes);
  }

    return spice_realloc(mem, n_blocks * n_block_bytes);
}
예제 #3
0
void *spice_malloc0(size_t n_bytes)
{
    void *mem;

    if (SPICE_LIKELY(n_bytes)) {
        mem = calloc(1, n_bytes);

        if (SPICE_LIKELY(mem != NULL)) {
            return mem;
        }

        MALLOC_ERROR("spice_malloc0: panic: unable to allocate %lu bytes\n",
                     (unsigned long)n_bytes);
    }
    return NULL;
}
예제 #4
0
void *spice_realloc(void *mem, size_t n_bytes)
{
    if (SPICE_LIKELY(n_bytes)) {
        mem = realloc(mem, n_bytes);

        if (SPICE_LIKELY(mem != NULL)) {
            return mem;
        }

        MALLOC_ERROR("spice_realloc: panic: unable to allocate %lu bytes\n",
                     (unsigned long)n_bytes);
    }

    if (mem) {
        free(mem);
    }

    return NULL;
}
/* !!! INUTILISEE, non testee !!! */
void Csc2updown_new(Sopalin_Data_t * sopalin_data, int me, const CscMatrix *cscmtx, UpDownVector *updovct,
		    /*const*/ SymbolMatrix *symbmtx, int n, MPI_Comm comm)
{
  SolverMatrix * datacode;
  PASTIX_FLOAT *tempy;
  PASTIX_INT    i;

#ifdef CSC_LOG
  fprintf(stdout, "-> Csc2updown_new \n");
#endif

  datacode = sopalin_data->datacode;

  MONOTHREAD_BEGIN;

  if (!(tempy = (PASTIX_FLOAT *)memAlloc(updovct->gnodenbr*sizeof(PASTIX_FLOAT)))) MALLOC_ERROR("tempy");
  sopalin_data->ptr_raff[0] = (void *)tempy;

  for (i=0;i<updovct->gnodenbr;i++)
    tempy[i] = (PASTIX_FLOAT)i;
  MONOTHREAD_END;

  SYNCHRO_THREAD;

  tempy = (PASTIX_FLOAT *)sopalin_data->ptr_raff[0];

  CscAx(sopalin_data, me, cscmtx, tempy, updovct->sm2xtab, symbmtx, updovct, comm);

  MONOTHREAD_BEGIN;
  memFree_null(tempy);
  MONOTHREAD_END;

#ifdef CSC_LOG
  fprintf(stdout, "<- Csc2updown_new \n");
#endif
}