00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "ocilib_internal.h"
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 void * OCI_MemAlloc(int ptr_type, int block_size, int block_count,
00046 boolean zero_fill)
00047 {
00048 void * ptr = NULL;
00049 size_t size = (size_t) (block_size * block_count);
00050
00051 ptr = (void *) malloc(size);
00052
00053 if (ptr != NULL)
00054 {
00055 if (zero_fill == TRUE)
00056 memset(ptr, 0, size);
00057 }
00058 else
00059 OCI_ExceptionMemory(ptr_type, size, NULL, NULL);
00060
00061 return ptr;
00062 }
00063
00064
00065
00066
00067
00068 void * OCI_MemRealloc(void * ptr_mem, int ptr_type, int block_size,
00069 int block_count)
00070 {
00071 void * ptr = NULL;
00072 size_t size = (size_t) (block_size * block_count);
00073
00074 ptr = (void *) realloc(ptr_mem, size);
00075
00076 if (ptr == NULL)
00077 {
00078 OCI_MemFree(ptr_mem);
00079
00080 OCI_ExceptionMemory(ptr_type, size, NULL, NULL);
00081 }
00082
00083 return ptr;
00084 }
00085
00086
00087
00088
00089
00090 void OCI_MemFree(void * ptr_mem)
00091 {
00092 if (ptr_mem != NULL)
00093 free(ptr_mem);
00094 }
00095
00096
00097
00098
00099
00100 sword OCI_HandleAlloc(CONST dvoid *parenth, dvoid **hndlpp, CONST ub4 type,
00101 CONST size_t xtramem_sz, dvoid **usrmempp)
00102 {
00103 sword ret = OCI_SUCCESS;
00104
00105 ret = OCIHandleAlloc(parenth, hndlpp, type, xtramem_sz, usrmempp);
00106
00107 if (ret == OCI_SUCCESS)
00108 {
00109 OCILib.nb_hndlp++;
00110 }
00111
00112 return ret;
00113 }
00114
00115
00116
00117
00118
00119 sword OCI_HandleFree(dvoid *hndlp, CONST ub4 type)
00120 {
00121 sword ret = OCI_SUCCESS;
00122
00123 if (hndlp != NULL)
00124 {
00125 OCILib.nb_hndlp--;
00126
00127 ret = OCIHandleFree(hndlp, type);
00128 }
00129
00130 return ret;
00131 }
00132
00133
00134
00135
00136
00137 sword OCI_DescriptorAlloc(CONST dvoid *parenth, dvoid **descpp, CONST ub4 type,
00138 CONST size_t xtramem_sz, dvoid **usrmempp)
00139 {
00140 sword ret = OCI_SUCCESS;
00141
00142 ret = OCIDescriptorAlloc(parenth, descpp, type, xtramem_sz, usrmempp);
00143
00144 if (ret == OCI_SUCCESS)
00145 {
00146 OCILib.nb_descp++;
00147 }
00148
00149 return ret;
00150 }
00151
00152
00153
00154
00155
00156 sword OCI_DescriptorFree(dvoid *descp, CONST ub4 type)
00157 {
00158 sword ret = OCI_SUCCESS;
00159
00160 if (descp != NULL)
00161 {
00162 OCILib.nb_descp--;
00163
00164 ret = OCIDescriptorFree(descp, type);
00165 }
00166
00167 return ret;
00168 }
00169
00170
00171
00172
00173
00174 sword OCI_ObjectNew(OCIEnv *env, OCIError *err, CONST OCISvcCtx *svc,
00175 OCITypeCode typecode, OCIType *tdo, dvoid *table,
00176 OCIDuration duration, boolean value,
00177 dvoid **instance)
00178 {
00179 sword ret = OCI_SUCCESS;
00180
00181 ret = OCIObjectNew(env, err, svc, typecode, tdo, table, duration, value, instance);
00182
00183 if (ret == OCI_SUCCESS)
00184 {
00185 OCILib.nb_objinst++;
00186 }
00187
00188 return ret;
00189 }
00190
00191
00192
00193
00194
00195 sword OCI_OCIObjectFree(OCIEnv *env, OCIError *err, dvoid *instance, ub2 flags)
00196 {
00197 sword ret = OCI_SUCCESS;
00198
00199 if (instance != NULL)
00200 {
00201 OCILib.nb_objinst--;
00202
00203 ret = OCIObjectFree(env, err, instance, flags);
00204 }
00205
00206 return ret;
00207 }
00208
00209