void IMG_sqlfile(Image_t *img, const char *filename) { assert(img != NULL); Buffer_t *b = BUF_createfromfilecstr(filename); if (b != NULL) { sqlite3_exec(img->db, BUF_getptr(b), NULL, NULL, NULL); BUF_free(b); } }
void IMG_free(Image_t *img) { assert(img != NULL); IMG_dbclose(img); for (int i = 1; i <= MAX_SECTIONS; i++) { Section_t *sec; sec = IMG_getsection(img, i); if (sec->buf_data != NULL) { BUF_free(sec->buf_data); } if (sec->buf_plan != NULL) { BUF_free(sec->buf_plan); } sec->data = NULL; sec->plan = NULL; } free(img); }
/****************************************************************************** * Fifo_get ******************************************************************************/ Int Fifo_get(Fifo_Handle hFifo, Ptr ptrPtr) { Int flush; Fifo_Elem * elem; Ptr * p = (Ptr *)ptrPtr; assert(hFifo); assert(ptrPtr); SEM_pend(&hFifo->mutex, SYS_FOREVER); flush = hFifo->flush; SEM_post(&hFifo->mutex); /* If pipe is already flushed, do not block */ if (flush) { return Dmai_EFLUSH; } /* Wait for element from other thread */ SEM_pend(&hFifo->sem, SYS_FOREVER); /* Handle flushed fifo */ SEM_pend(&hFifo->mutex, SYS_FOREVER); flush = hFifo->flush; if (flush) { hFifo->flush = FALSE; } SEM_post(&hFifo->mutex); if (flush) { return Dmai_EFLUSH; } /* Get an element from the Fifo queue */ elem = (Fifo_Elem *)QUE_get(&hFifo->queue); *p = elem->ptr; if (BUF_free(hFifo->hBufPool, elem) != TRUE) { return Dmai_EFAIL; } SEM_pend(&hFifo->mutex, SYS_FOREVER); hFifo->numBufs--; SEM_post(&hFifo->mutex); return Dmai_EOK; }