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
00046 (
00047 int ptr_type,
00048 size_t block_size,
00049 size_t block_count,
00050 boolean zero_fill
00051 )
00052 {
00053 void * ptr = NULL;
00054 size_t size = (size_t) (block_size * block_count);
00055
00056 ptr = (void *) malloc(size);
00057
00058 if (ptr != NULL)
00059 {
00060 if (zero_fill == TRUE)
00061 memset(ptr, 0, size);
00062 }
00063 else
00064 OCI_ExceptionMemory(ptr_type, size, NULL, NULL);
00065
00066 return ptr;
00067 }
00068
00069
00070
00071
00072
00073 void * OCI_MemRealloc
00074 (
00075 void * ptr_mem,
00076 int ptr_type,
00077 size_t block_size,
00078 size_t block_count
00079 )
00080 {
00081 void * ptr = NULL;
00082 size_t size = (size_t) (block_size * block_count);
00083
00084 ptr = (void *) realloc(ptr_mem, size);
00085
00086 if (ptr == NULL)
00087 {
00088 OCI_MemFree(ptr_mem);
00089
00090 OCI_ExceptionMemory(ptr_type, size, NULL, NULL);
00091 }
00092
00093 return ptr;
00094 }
00095
00096
00097
00098
00099
00100 void OCI_MemFree
00101 (
00102 void * ptr_mem
00103 )
00104 {
00105 if (ptr_mem != NULL)
00106 free(ptr_mem);
00107 }
00108
00109
00110
00111
00112
00113 sword OCI_HandleAlloc
00114 (
00115 CONST dvoid *parenth,
00116 dvoid **hndlpp,
00117 CONST ub4 type,
00118 CONST size_t xtramem_sz,
00119 dvoid **usrmempp
00120 )
00121 {
00122 sword ret = OCI_SUCCESS;
00123
00124 ret = OCIHandleAlloc(parenth, hndlpp, type, xtramem_sz, usrmempp);
00125
00126 if (ret == OCI_SUCCESS)
00127 {
00128 OCILib.nb_hndlp++;
00129 }
00130
00131 return ret;
00132 }
00133
00134
00135
00136
00137
00138 sword OCI_HandleFree
00139 (
00140 dvoid *hndlp,
00141 CONST ub4 type
00142 )
00143 {
00144 sword ret = OCI_SUCCESS;
00145
00146 if (hndlp != NULL)
00147 {
00148 OCILib.nb_hndlp--;
00149
00150 ret = OCIHandleFree(hndlp, type);
00151 }
00152
00153 return ret;
00154 }
00155
00156
00157
00158
00159
00160 sword OCI_DescriptorAlloc
00161 (
00162 CONST dvoid *parenth,
00163 dvoid **descpp,
00164 CONST ub4 type,
00165 CONST size_t xtramem_sz,
00166 dvoid **usrmempp
00167 )
00168 {
00169 sword ret = OCI_SUCCESS;
00170
00171 ret = OCIDescriptorAlloc(parenth, descpp, type, xtramem_sz, usrmempp);
00172
00173 if (ret == OCI_SUCCESS)
00174 {
00175 OCILib.nb_descp++;
00176 }
00177
00178 return ret;
00179 }
00180
00181
00182
00183
00184
00185 sword OCI_DescriptorArrayAlloc
00186 (
00187 CONST dvoid *parenth,
00188 dvoid **descpp,
00189 CONST ub4 type,
00190 ub4 nb_elem,
00191 CONST size_t xtramem_sz,
00192 dvoid **usrmempp
00193 )
00194 {
00195 sword ret = OCI_SUCCESS;
00196
00197 #if OCI_VERSION_COMPILE >= OCI_11_1
00198
00199 if (OCILib.version_runtime >= OCI_11_1)
00200 {
00201 ret = OCIArrayDescriptorAlloc(parenth, descpp, type, nb_elem,
00202 xtramem_sz, usrmempp);
00203
00204 }
00205 else
00206
00207 #endif
00208
00209 {
00210 ub4 i;
00211
00212 for(i = 0; (i < nb_elem) && (ret == OCI_SUCCESS); i++)
00213 {
00214 ret = OCIDescriptorAlloc(parenth, &descpp[i], type, xtramem_sz, usrmempp);
00215 }
00216 }
00217
00218 if (ret == OCI_SUCCESS)
00219 {
00220 OCILib.nb_descp += nb_elem;
00221 }
00222
00223 return ret;
00224 }
00225
00226
00227
00228
00229
00230 sword OCI_DescriptorFree
00231 (
00232 dvoid *descp,
00233 CONST ub4 type
00234 )
00235 {
00236 sword ret = OCI_SUCCESS;
00237
00238 if (descp != NULL)
00239 {
00240 OCILib.nb_descp--;
00241
00242 ret = OCIDescriptorFree(descp, type);
00243 }
00244
00245 return ret;
00246 }
00247
00248
00249
00250
00251
00252 sword OCI_DescriptorArrayFree
00253 (
00254 dvoid **descp,
00255 CONST ub4 type,
00256 ub4 nb_elem
00257 )
00258 {
00259 sword ret = OCI_SUCCESS;
00260
00261 if (descp != NULL)
00262 {
00263 #if OCI_VERSION_COMPILE >= OCI_11_1
00264
00265 if (OCILib.version_runtime >= OCI_11_1)
00266 {
00267 ret = OCIArrayDescriptorFree(descp, type);
00268
00269 }
00270 else
00271
00272 #endif
00273
00274 {
00275 ub4 i;
00276
00277 for(i = 0; (i < nb_elem) && (ret == OCI_SUCCESS); i++)
00278 {
00279 ret = OCIDescriptorFree(descp[i], type);
00280 }
00281 }
00282
00283 OCILib.nb_descp -= nb_elem;
00284 }
00285
00286 return ret;
00287 }
00288
00289
00290
00291
00292
00293 sword OCI_ObjectNew
00294 (
00295 OCIEnv *env,
00296 OCIError *err,
00297 CONST OCISvcCtx *svc,
00298 OCITypeCode typecode,
00299 OCIType *tdo,
00300 dvoid *table,
00301 OCIDuration duration,
00302 boolean value,
00303 dvoid **instance
00304 )
00305 {
00306 sword ret = OCI_SUCCESS;
00307
00308 ret = OCIObjectNew(env, err, svc, typecode, tdo, table, duration, value, instance);
00309
00310 if (ret == OCI_SUCCESS)
00311 {
00312 OCILib.nb_objinst++;
00313 }
00314
00315 return ret;
00316 }
00317
00318
00319
00320
00321
00322 sword OCI_OCIObjectFree
00323 (
00324 OCIEnv *env,
00325 OCIError *err,
00326 dvoid *instance,
00327 ub2 flags
00328 )
00329 {
00330 sword ret = OCI_SUCCESS;
00331
00332 if (instance != NULL)
00333 {
00334 OCILib.nb_objinst--;
00335
00336 ret = OCIObjectFree(env, err, instance, flags);
00337 }
00338
00339 return ret;
00340 }
00341