boolean OCI_API OCI_FileFree ( OCI_File *file ) { boolean res = TRUE; OCI_CHECK_PTR(OCI_IPC_FILE, file, FALSE); OCI_CHECK_OBJECT_FETCHED(file, FALSE); OCI_FREE(file->dir); OCI_FREE(file->name); if (file->hstate == OCI_OBJECT_ALLOCATED) { OCI_DescriptorFree((dvoid *) file->handle, (ub4) OCI_DTYPE_LOB); } if (file->hstate != OCI_OBJECT_ALLOCATED_ARRAY) { OCI_FREE(file); } OCI_RESULT(res); return res; }
void OCI_ErrorFree ( OCI_Error *err ) { OCI_FREE(err); }
OCI_List * OCI_ListCreate ( int type ) { OCI_List *list = NULL; /* allocate list */ list = (OCI_List *) OCI_MemAlloc(OCI_IPC_LIST, sizeof(*list), (size_t) 1, TRUE); /* create a mutex on multithreaded environments */ if (list != NULL) { list->type = type; if (OCI_LIB_THREADED) { list->mutex = OCI_MutexCreateInternal(); if (list->mutex == NULL) { OCI_FREE(list); } } } return list; }
OCI_Item * OCI_ListCreateItem ( int type, int size ) { OCI_Item *item = NULL; /* allocate list item entry */ item = (OCI_Item *) OCI_MemAlloc(OCI_IPC_LIST_ITEM, sizeof(*item), (size_t) 1, TRUE); if (item != NULL) { /* allocate item data buffer */ item->data = (void *) OCI_MemAlloc(type, (size_t) size, (size_t) 1, TRUE); if (item->data == NULL) { OCI_FREE(item); } } return item; }
boolean OCI_API OCI_IntervalFree2(OCI_Library *pOCILib, OCI_Interval *itv) { OCI_CHECK_PTR(pOCILib, OCI_IPC_INTERVAL, itv, FALSE); //OCI_CHECK_INTERVAL_ENABLED(pOCILib, itv->con, FALSE); #if OCI_VERSION_COMPILE >= OCI_9_0 OCI_CHECK_OBJECT_FETCHED(itv, FALSE); if (itv->hstate == OCI_OBJECT_ALLOCATED) { ub4 htype = 0; if (itv->type == OCI_INTERVAL_YM) htype = OCI_DTYPE_INTERVAL_YM; else if (itv->type == OCI_INTERVAL_DS) htype = OCI_DTYPE_INTERVAL_DS; OCI_DescriptorFree2(pOCILib, (dvoid *) itv->handle, htype); } if (itv->hstate != OCI_OBJECT_ALLOCATED_ARRAY) { OCI_FREE(itv); } #endif OCI_RESULT(pOCILib, TRUE); return TRUE; }
boolean OCI_API OCI_DequeueFree ( OCI_Dequeue *dequeue ) { OCI_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue, FALSE); /* Unsubscribe notification if needed */ if (dequeue->subhp != NULL) { OCI_DequeueUnsubscribe(dequeue); } /* free local message */ if (dequeue->msg != NULL) { OCI_MsgFree(dequeue->msg); } /* free local agent */ if (dequeue->agent != NULL) { OCI_AgentFree(dequeue->agent); } /* free OCI descriptor */ OCI_DescriptorFree((dvoid *) dequeue->opth, OCI_DTYPE_AQDEQ_OPTIONS); /* free strings */ OCI_FREE(dequeue->name); OCI_FREE(dequeue->pattern); OCI_FREE(dequeue->consumer); /* free misc. */ OCI_FREE(dequeue->agent_list); OCI_FREE(dequeue); return TRUE; }
boolean OCI_API OCI_EnqueueFree ( OCI_Library *pOCILib, OCI_Enqueue *enqueue ) { OCI_CHECK_PTR(pOCILib, OCI_IPC_ENQUEUE, enqueue, FALSE); /* free OCI descriptor */ OCI_DescriptorFree2(pOCILib, (dvoid *) enqueue->opth, OCI_DTYPE_AQENQ_OPTIONS); OCI_FREE(enqueue->name); OCI_FREE(enqueue); return TRUE; }
boolean OCI_API OCI_MsgSetConsumers ( OCI_Msg *msg, OCI_Agent **consumers, unsigned int count ) { boolean res = TRUE; OCIAQAgent **handles = NULL; OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE); /* allocate local array of OCIAQAgent handles if needed */ if ((consumers != NULL) && (count > 0)) { handles = (OCIAQAgent **) OCI_MemAlloc(OCI_IPC_ARRAY,sizeof(OCIAQAgent *), count, FALSE); if (handles != NULL) { unsigned int i; for(i = 0; i < count; i++) { handles[i] = consumers[i]->handle; } } } else { count = 0; } OCI_CALL2 ( res, msg->typinf->con, OCIAttrSet((dvoid *) msg->proph, (ub4 ) OCI_DTYPE_AQMSG_PROPERTIES, (dvoid *) handles, (ub4 ) count, (ub4 ) OCI_ATTR_RECIPIENT_LIST, msg->typinf->con->err) ) /* free local array of OCIAQAgent handles if needed */ if (handles != NULL) { OCI_FREE(handles); } OCI_RESULT(res); return res; }
boolean OCI_TypeInfoClose(OCI_TypeInfo *typinf) { ub2 i; OCI_CHECK(typinf == NULL, FALSE); for (i=0; i < typinf->nb_cols; i++) { OCI_FREE(typinf->cols[i].name); } OCI_FREE(typinf->cols); OCI_FREE(typinf->name); OCI_FREE(typinf->schema); OCI_FREE(typinf->offsets); return TRUE; }
boolean OCI_API OCI_DateFree(OCI_Library *pOCILib, OCI_Date *date) { OCI_CHECK_PTR(pOCILib, OCI_IPC_DATE, date, FALSE); OCI_CHECK_OBJECT_FETCHED(date, FALSE); if (date->allocated == TRUE) { OCI_FREE(date->handle); } if (date->hstate != OCI_OBJECT_ALLOCATED_ARRAY) { OCI_FREE(date); } OCI_RESULT(pOCILib, TRUE); return TRUE; }
boolean OCI_ListRemove ( OCI_List *list, void *data ) { OCI_Item *item = NULL; OCI_Item *temp = NULL; OCI_CHECK(list == NULL, FALSE); OCI_CHECK(data == NULL, FALSE); if (list->mutex != NULL) { OCI_MutexAcquire(list->mutex); } item = list->head; while (item != NULL) { if (item->data == data) { if (temp) { temp->next = item->next; } /* if item was the first entry, readjust the first list entry to next element */ if (item == list->head) { list->head = item->next; } OCI_FREE(item); break; } temp = item; item = item->next; } list->count--; if (list->mutex != NULL) { OCI_MutexRelease(list->mutex); } return TRUE; }
boolean OCI_ListClear ( OCI_List *list ) { OCI_Item *item = NULL; OCI_Item *temp = NULL; OCI_CHECK(list == NULL, FALSE); if (list->mutex != NULL) { OCI_MutexAcquire(list->mutex); } /* walk along the list to free item's buffer */ item = list->head; while (item != NULL) { temp = item; item = item->next; /* free data */ OCI_FREE(temp->data); OCI_FREE(temp); } list->head = NULL; list->count = 0; if (list->mutex != NULL) { OCI_MutexRelease(list->mutex); } return TRUE; }
boolean OCI_ArrayClose ( OCI_Array *arr ) { unsigned int i; OCI_CHECK(NULL == arr, FALSE) if ( (OCI_CDT_NUMERIC != arr->elem_type ) && (OCI_CDT_TEXT != arr->elem_type ) && (OCI_CDT_RAW != arr->elem_type ) ) { /* Cleanup OCILIB Objects */ for (i = 0; i < arr->nb_elem; i++) { OCI_FreeObjectFromType(arr->tab_obj[i], arr->elem_type); } } /* free OCI descriptors */ if (OCI_UNKNOWN != arr->handle_type) { OCI_DescriptorArrayFree ( (dvoid **) arr->mem_handle, (ub4 ) arr->handle_type, (ub4 ) arr->nb_elem ); } OCI_FREE(arr->mem_handle) OCI_FREE(arr->mem_struct) OCI_FREE(arr->tab_obj) return TRUE; }
boolean OCI_API OCI_HashFree ( OCI_HashTable *table ) { unsigned int i; OCI_HashEntry *e1, *e2; OCI_HashValue *v1, *v2; OCI_CHECK_PTR(OCI_IPC_HASHTABLE, table, FALSE); for (i = 0; i < table->size; i++) { e1 = table->items[i]; while (e1 != NULL) { e2 = e1; e1 = e1->next; v1 = e2->values; while (v1 != NULL) { v2 = v1; v1 = v1->next; if (table->type == OCI_HASH_STRING) { OCI_FREE(v2->value.p_mtext); } OCI_FREE(v2); } if (e2->key) { OCI_FREE(e2->key); } if (e2) { OCI_FREE(e2); } } } if (table->items != NULL) { OCI_FREE(table->items); } OCI_FREE(table); OCI_RESULT(TRUE); return TRUE; }
boolean OCI_ListFree ( OCI_List *list ) { boolean res = TRUE; OCI_CHECK(list == NULL, FALSE); OCI_ListClear(list); if (list->mutex != NULL) { res = OCI_MutexFree(list->mutex); } OCI_FREE(list); return res; }
boolean OCI_BindFree ( OCI_Bind *bnd ) { boolean res = TRUE; OCI_CHECK(NULL == bnd, FALSE) if (OCI_BAM_INTERNAL == bnd->stmt->bind_alloc_mode) { if (bnd->is_array) { res = OCI_ArrayFreeFromHandles(bnd->input); } else { switch (bnd->type) { case OCI_CDT_NUMERIC: case OCI_CDT_TEXT: { OCI_MemFree(bnd->input); if (bnd->alloc) { OCI_FREE(bnd->buffer.data) } break; } default: { OCI_FreeObjectFromType(bnd->input, bnd->type); } } } } else { if (bnd->alloc)
boolean OCI_API OCI_DequeueSetAgentList ( OCI_Dequeue *dequeue, OCI_Agent **consumers, unsigned int count ) { boolean res = TRUE; OCI_CHECK_PTR(OCI_IPC_ENQUEUE, dequeue, FALSE); OCI_FREE(dequeue->agent_list); if ((consumers != NULL) && (count > 0)) { dequeue->agent_list = (OCIAQAgent **) OCI_MemAlloc(OCI_IPC_ARRAY, sizeof(OCIAQAgent *), count, FALSE); if (dequeue->agent_list != NULL) { unsigned int i; for(i = 0; i < count; i++) { dequeue->agent_list[i] = consumers[i]->handle; } dequeue->agent_count = (ub4) count; } else { res = FALSE; } } OCI_RESULT(res); return res; }
boolean OCI_PoolClose ( OCI_Pool *pool ) { boolean res = TRUE; OCI_CHECK_PTR(OCI_IPC_POOL, pool, FALSE); /* free all connections */ OCI_ListForEach(pool->cons, (POCI_LIST_FOR_EACH) OCI_ConnectionClose); OCI_ListClear(pool->cons); OCI_ListFree(pool->cons); pool->cons = NULL; if (OCI_LIB_THREADED) { OCI_MutexFree(pool->mutex); } #if OCI_VERSION_COMPILE >= OCI_9_0 if (OCILib.version_runtime >= OCI_9_0) { /* close pool handle */ if (pool->handle != NULL) { if (pool->htype == OCI_HTYPE_CPOOL) { OCI_CALL0 ( res, pool->err, OCIConnectionPoolDestroy(pool->handle, pool->err, (ub4) OCI_DEFAULT) ) } #if OCI_VERSION_COMPILE >= OCI_9_2 else { OCI_CALL0 ( res, pool->err, OCISessionPoolDestroy(pool->handle, pool->err, (ub4) OCI_SPD_FORCE) ) } #endif OCI_HandleFree((void *) pool->handle, (ub4) pool->htype); } #if OCI_VERSION_COMPILE >= OCI_9_2 /* close authentification handle */ if (pool->authp != NULL) { OCI_HandleFree((void *) pool->authp, (ub4) OCI_HTYPE_AUTHINFO); } #endif /* close error handle */ if (pool->err != NULL) { OCI_HandleFree((void *) pool->err, (ub4) OCI_HTYPE_ERROR); } } #endif pool->err = NULL; pool->handle = NULL; pool->authp = NULL; /* free strings */ OCI_FREE(pool->name); OCI_FREE(pool->db); OCI_FREE(pool->user); OCI_FREE(pool->pwd); return res; }
boolean OCI_API OCI_HashFree ( OCI_HashTable *table ) { unsigned int i; OCI_HashEntry *e1 = NULL, *e2 = NULL; OCI_HashValue *v1 = NULL, *v2 = NULL; OCI_LIB_CALL_ENTER(boolean, FALSE) OCI_CHECK_PTR(OCI_IPC_HASHTABLE, table) if (table->items) { for (i = 0; i < table->size; i++) { e1 = table->items[i]; while (e1) { e2 = e1; e1 = e1->next; v1 = e2->values; while (v1) { v2 = v1; v1 = v1->next; if (OCI_HASH_STRING == table->type) { OCI_FREE(v2->value.p_text) } OCI_FREE(v2) } if (e2->key) { OCI_FREE(e2->key) } if (e2) { OCI_FREE(e2) } } } OCI_FREE(table->items) } OCI_FREE(table) call_status = TRUE; OCI_LIB_CALL_EXIT() }
boolean OCI_API OCI_ElemFree2(OCI_Library *pOCILib, OCI_Elem *elem, ExceptionSink* xsink) { assert(elem); //OCI_CHECK_PTRQ(pOCILib, OCI_IPC_ELEMENT, elem, FALSE, xsink); OCI_CHECK_OBJECT_FETCHED(elem, FALSE); /* if the element has sub-objects that have been fetched, we need to free these objects */ if (elem->obj != NULL) { OCI_Datatype * data = (OCI_Datatype *) elem->obj; if (data->hstate == OCI_OBJECT_FETCHED_CLEAN) data->hstate = OCI_OBJECT_FETCHED_DIRTY; switch (elem->typinf->cols[0].type) { case OCI_CDT_DATETIME: OCI_DateFree(pOCILib, (OCI_Date *) elem->obj); break; case OCI_CDT_LOB: OCI_LobFree(pOCILib, (OCI_Lob *) elem->obj, xsink); break; case OCI_CDT_FILE: assert(false); //OCI_FileFree(pOCILib, (OCI_File *) elem->obj); break; case OCI_CDT_OBJECT: OCI_ObjectFree2(pOCILib, (OCI_Object *) elem->obj, xsink); break; case OCI_CDT_COLLECTION: OCI_CollFree2(pOCILib, (OCI_Coll *) elem->obj, xsink); break; case OCI_CDT_TIMESTAMP: OCI_TimestampFree2(pOCILib, (OCI_Timestamp *) elem->obj); break; case OCI_CDT_INTERVAL: OCI_IntervalFree2(pOCILib, (OCI_Interval *) elem->obj); break; case OCI_CDT_REF: assert(false); //OCI_RefFree(pOCILib, (OCI_Ref *) elem->obj); break; } } if ((elem->hstate == OCI_OBJECT_ALLOCATED) && (elem->typinf->cols[0].type == OCI_CDT_NUMERIC)) { OCI_FREE(elem->handle); } OCI_FREE(elem->buf); OCI_FREE(elem); OCI_RESULT(pOCILib, TRUE); return TRUE; }
boolean OCI_API OCI_MsgFree ( OCI_Msg *msg ) { boolean res = TRUE; OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE); /* free local OCI_Agent object */ if (msg->sender != NULL) { OCI_AgentFree(msg->sender); } /* free internal OCI_Object handle if payload is not RAW */ if (msg->obj != NULL) { msg->obj->hstate = OCI_OBJECT_ALLOCATED; OCI_ObjectFree(msg->obj); msg->obj = NULL; } /* free message RAW payload if necessary */ if ((msg->typinf->tcode == OCI_UNKNOWN)&& ( msg->id != NULL)) { OCI_CALL2 ( res, msg->typinf->con, OCIRawResize(msg->typinf->con->env, msg->typinf->con->err, 0, (OCIRaw **) &msg->payload) ) } /* free message ID */ if (msg->id != NULL) { OCI_CALL2 ( res, msg->typinf->con, OCIRawResize(msg->typinf->con->env, msg->typinf->con->err, 0, (OCIRaw **) &msg->id) ) } msg->id = NULL; /* free OCI descriptor */ OCI_DescriptorFree((dvoid *) msg->proph, OCI_DTYPE_AQMSG_PROPERTIES); OCI_FREE(msg); return res; }