File: envrnmnt.c-01.v6.24-test.diff

package info (click to toggle)
python-clips 1.0.7.348%2Bclips-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,332 kB
  • ctags: 2,481
  • sloc: ansic: 17,065; python: 5,668; sh: 20; makefile: 12
file content (114 lines) | stat: -rw-r--r-- 3,528 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
--- ../clipssrc0624_orig/envrnmnt.c	Thu Jun 15 12:04:00 2006
+++ ../clipssrc/envrnmnt.c	Fri Jun 16 22:45:10 2006
@@ -50,6 +50,30 @@
 
 #define SIZE_ENVIRONMENT_HASH  131
 
+
+/* use Python memory allocator when compiling PyCLIPS */
+#ifdef PYCLIPS
+#include <Python.h>
+void *PyCLIPS_Malloc(size_t s);
+void PyCLIPS_Free(void *p);
+#if !BLOCK_MEMORY
+   #undef malloc
+   #define malloc PyCLIPS_Malloc
+   #undef free
+   #define free PyCLIPS_Free
+#endif /* BLOCK_MEMORY */
+#endif /* PYCLIPS */
+
+
+/* enable inhibition of fatal environment errors */
+#ifdef PYCLIPS
+int PyCLIPS_EnableFatal();
+#define FPRINTF if(PyCLIPS_EnableFatal()) fprintf
+#else
+#define FPRINTF fprintf
+#endif /* PYCLIPS */
+
+
 /***************************************/
 /* LOCAL INTERNAL FUNCTION DEFINITIONS */
 /***************************************/
@@ -92,7 +116,7 @@
    
    if (size <= 0)
      {
-      printf("\n[ENVRNMNT1] Environment data position %d allocated with size of 0 or less.\n",position);      
+      FPRINTF(stderr, "\n[ENVRNMNT1] Environment data position %d allocated with size of 0 or less.\n",position);
       return(FALSE);
      }
      
@@ -102,7 +126,7 @@
    
    if (position >= MAXIMUM_ENVIRONMENT_POSITIONS)
      {
-      printf("\n[ENVRNMNT2] Environment data position %d exceeds the maximum allowed.\n",position);      
+      FPRINTF(stderr, "\n[ENVRNMNT2] Environment data position %d exceeds the maximum allowed.\n",position);
       return(FALSE);
      }
      
@@ -112,7 +136,7 @@
    
    if (theEnvironment->theData[position] != NULL)
      {
-      printf("\n[ENVRNMNT3] Environment data position %d already allocated.\n",position);      
+      FPRINTF(stderr, "\n[ENVRNMNT3] Environment data position %d already allocated.\n",position);
       return(FALSE);
      }
      
@@ -123,7 +147,7 @@
    theEnvironment->theData[position] = malloc(size);
    if (theEnvironment->theData[position] == NULL)
      {
-      printf("\n[ENVRNMNT4] Environment data position %d could not be allocated.\n",position);      
+      FPRINTF(stderr, "\n[ENVRNMNT4] Environment data position %d could not be allocated.\n",position);
       return(FALSE);
      }
    
@@ -193,7 +217,7 @@
 
    if (EnvironmentHashTable == NULL)
      {
-      printf("\n[ENVRNMNT4] Unable to initialize environment hash table.\n");      
+      FPRINTF(stderr, "\n[ENVRNMNT4] Unable to initialize environment hash table.\n");
       return;
      }
 
@@ -318,7 +342,7 @@
   
    if (theEnvironment == NULL)
      {
-      printf("\n[ENVRNMNT5] Unable to create new environment.\n");
+      FPRINTF(stderr, "\n[ENVRNMNT5] Unable to create new environment.\n");
       return(NULL);
      }
 
@@ -327,7 +351,7 @@
    if (theData == NULL)
      {
       free(theEnvironment);
-      printf("\n[ENVRNMNT6] Unable to create environment data.\n");
+      FPRINTF(stderr, "\n[ENVRNMNT6] Unable to create environment data.\n");
       return(NULL);
      }
 
@@ -355,7 +379,7 @@
      {
       free(theEnvironment->theData);
       free(theEnvironment);
-      printf("\n[ENVRNMNT7] Unable to create environment data.\n");
+      FPRINTF(stderr, "\n[ENVRNMNT7] Unable to create environment data.\n");
       return(NULL);
      }
 
@@ -540,7 +564,7 @@
      
    if ((theMemData->MemoryAmount != 0) || (theMemData->MemoryCalls != 0))
      {
-      printf("\n[ENVRNMNT8] Environment data not fully deallocated.\n"); 
+      FPRINTF(stderr, "\n[ENVRNMNT8] Environment data not fully deallocated.\n");
       rv = FALSE;     
      }