f77_aloc.c 684 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "f2c.h"
  2. #undef abs
  3. #undef min
  4. #undef max
  5. #include "stdio.h"
  6. static integer memfailure = 3;
  7. #ifdef KR_headers
  8. extern char *malloc();
  9. extern void exit_();
  10. char *
  11. F77_aloc(Len, whence) integer Len; char *whence;
  12. #else
  13. #include "stdlib.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. extern void exit_(integer*);
  21. #ifdef __cplusplus
  22. }
  23. #endif
  24. char *
  25. F77_aloc(integer Len, const char *whence)
  26. #endif
  27. {
  28. char *rv;
  29. unsigned int uLen = (unsigned int) Len; /* for K&R C */
  30. if (!(rv = (char*)malloc(uLen))) {
  31. fprintf(stderr, "malloc(%u) failure in %s\n",
  32. uLen, whence);
  33. exit_(&memfailure);
  34. }
  35. return rv;
  36. }
  37. #ifdef __cplusplus
  38. }
  39. #endif