⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 freestor.cpp

📁 不错的国外的有限元程序代码,附带详细的manual,可以节省很多的底层工作.
💻 CPP
字号:
//   file FREESTOR.C

#include "freestor.h"
#include "compiler.def"
#include "debug.def"
#include <stdio.h>
#include <stdlib.h>


double*  allocDouble (int n)
   // Allocates and returns an array of n doubles. Issues an error message if
   // the free store is exhausted.
{
   double* answer ;

#  ifdef DEBUG
      if (! n) {
	 printf ("cannot allocate 0 coefficients in fucntion allocDouble\n");
	 exit(0) ;}
#  endif

   answer = (double*) calloc(n,sizeof(double)) ;
   if (answer)
      return answer ;
   else
      freeStoreError() ;
   return NULL;
}


int*  allocInt (int n)
   // Allocates and returns an array of n integers. Issues an error message
   // if the free store is exhausted.
{
   int* answer ;

#  ifdef DEBUG
      if (! n) {
	 printf ("cannot allocate 0 coefficients in function 'allocInt'\n") ;
	 exit(0) ;}
#  endif

   answer = (int*) calloc(n,sizeof(int)) ;
   if (answer)
      return answer ;
   else
      freeStoreError() ;
   return NULL;
}


void  freeStoreError ()
   // This function is called whenever operator "new" is unable to allocate 
   // memory.
{
   printf ("Sorry : free store exhausted \n") ;
   exit(0) ;
}


void  freeDouble (double* a)
   // Deallocates the list of decimals 'a'.
{
#ifdef SUN_STATION
   free ((char*)a) ;        /* the Sun compiler is really lousy */
#else
   free (a) ;
#endif
}


void  freeInt (int* a)
   // Deallocates the list of integers 'a'.
{
#ifdef SUN_STATION
   free ((char*)a) ;        /* see above */
#else
   free (a) ;
#endif
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -