Esempio n. 1
0
OCSPClientCertID::~OCSPClientCertID()
{
	freeData(mIssuerName);
	freeData(mIssuerPubKey);
	freeData(mSubjectSerial);
	freeData(mEncoded);
}
Esempio n. 2
0
int gWaveform::alloc(int datasize) {

	ratio = chan->wave->size / (float) datasize;

	if (ratio < 2)
		return 0;

	freeData();

	data.size = datasize;
	data.sup  = (int*) malloc(data.size * sizeof(int));
	data.inf  = (int*) malloc(data.size * sizeof(int));

	int offset = h() / 2;
	int zero   = y() + offset; // center, zero amplitude (-inf dB)


	for (int i=0; i<data.size; i++) {

		int pp;  // point prev
		int pn;  // point next

		/* resampling the waveform, hardcore way. Many thanks to
		 * http://fourier.eng.hmc.edu/e161/lectures/resize/node3.html
		 * Note: we use
		 * 	 p = j * (m-1 / n)
		 * instead of
		 * 	 p = j * (m-1 / n-1)
		 * in order to obtain 'datasize' cells to parse (and not datasize-1) */

		pp = i * ((chan->wave->size - 1) / (float) datasize);
		pn = (i+1) * ((chan->wave->size - 1) / (float) datasize);

		if (pp % 2 != 0) pp -= 1;
		if (pn % 2 != 0) pn -= 1;

		float peaksup = 0.0f;
		float peakinf = 0.0f;

		int k = pp;
		while (k < pn) {
			if (chan->wave->data[k] > peaksup)
				peaksup = chan->wave->data[k];    // Left data only
			else
			if (chan->wave->data[k] <= peakinf)
				peakinf = chan->wave->data[k];    // Left data only
			k += 2;
		}

		data.sup[i] = zero - (peaksup * chan->boost * offset);
		data.inf[i] = zero - (peakinf * chan->boost * offset);

		// avoid window overflow

		if (data.sup[i] < y())       data.sup[i] = y();
		if (data.inf[i] > y()+h()-1) data.inf[i] = y()+h()-1;
	}
	recalcPoints();
	return 1;
}
Esempio n. 3
0
BaseVector::~BaseVector() {
  for (uint i = 0; i < m_size; ++i) {
    tvRefcountedDecRef(&m_data[i]);
  }

  freeData();
}
void NNRegressionFactory::deserialize( Object *parent , SerializeObject& so )
{
	freeData();

	vars = ( NNVariables * )so.getPropObject( "variables" , true );
	nPerceptronIDLast = so.getPropInt( "nPerceptronIDLast" );
}
Esempio n. 5
0
void PagePositionHandler::update(PageView** viewPages, int viewPagesLen,
                                 int maxY)
{
    XOJ_CHECK_TYPE(PagePositionHandler);

    freeData();

    this->maxY = maxY;

    PagePosition* lastPp = new PagePosition();
    addData(lastPp);

    for (int i = 0; i < viewPagesLen; i++)
    {

        PageView* pv = viewPages[i];

        if (!lastPp->add(pv))
        {
            PagePosition* pp = new PagePosition(pv);
            lastPp->y2 = pp->y1 - 1;
            lastPp = pp;
            addData(pp);
        }
    }

    PagePosition* pp = new PagePosition();
    pp->y1 = lastPp->y2 + 1;
    pp->y2 = maxY;
    addData(pp);
}
int main() {
  struct node_t *list = NULL;

  /* Create a long singly-linked list with optional data.
  */

  int dataNotFinished = 0;

  do {
    append(&list);
  } while(__VERIFIER_nondet_int());

/*
Do something with data.
  displayData();
*/

//  free list and data
  while (list) {
    struct node_t *next = list->next;
    freeData(list->data);
    free(list);
    list = next;
  }

  return 0;
}
Esempio n. 7
0
bool BitmapData::loadTGA(Common::SeekableReadStream *data) {
	Image::TGADecoder dec;
	bool success = dec.loadStream(*data);

	if (!success)
		return false;

	const Graphics::Surface *origSurf = dec.getSurface();
	Graphics::PixelFormat pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
	Graphics::Surface *surf = origSurf->convertTo(pixelFormat);

	_width = surf->w;
	_height = surf->h;
	_format = 1;
	_x = _y = 0;
	_bpp = 4;
	_colorFormat = BM_RGBA;
	_numImages = 1;
	_data = new Graphics::PixelBuffer[1];
	_data[0].set(pixelFormat, (unsigned char *)surf->getPixels());

	g_driver->createBitmap(this);

	freeData();
	delete surf;

	return true;
}
void ProfileDataContainer::switchStorageToAshmem(int ashmemfd) {
    int regionSize = ashmem_get_size_region(ashmemfd);
    if (regionSize < 0) {
        int err = errno;
        ALOGW("Failed to get ashmem region size from fd %d, err %d %s", ashmemfd, err,
              strerror(err));
        return;
    }
    if (regionSize < static_cast<int>(sizeof(ProfileData))) {
        ALOGW("Ashmem region is too small! Received %d, required %u", regionSize,
              static_cast<unsigned int>(sizeof(ProfileData)));
        return;
    }
    ProfileData* newData = reinterpret_cast<ProfileData*>(
            mmap(NULL, sizeof(ProfileData), PROT_READ | PROT_WRITE, MAP_SHARED, ashmemfd, 0));
    if (newData == MAP_FAILED) {
        int err = errno;
        ALOGW("Failed to move profile data to ashmem fd %d, error = %d", ashmemfd, err);
        return;
    }

    newData->mergeWith(*mData);
    freeData();
    mData = newData;
    mIsMapped = true;
}
Esempio n. 9
0
	//-----------------------------------------------------------------------------
	Image & Image::operator = ( const Image &img )
	{
		freeData();

		m_uWidth = img.m_uWidth;
		m_uHeight = img.m_uHeight;
		m_uDepth = img.m_uDepth;
		m_eFormat = img.m_eFormat;
		m_uSize = img.m_uSize;
		m_uFlags = img.m_uFlags;
		m_ucPixelSize = img.m_ucPixelSize;
		m_uNumMipmaps = img.m_uNumMipmaps;
		m_bAutoDelete = img.m_bAutoDelete;
		//Only create/copy when previous data was not dynamic data
		if( m_bAutoDelete )
		{
			m_pBuffer = new uchar[ m_uSize ];
			memcpy( m_pBuffer, img.m_pBuffer, m_uSize );
		}
		else
		{
			m_pBuffer = img.m_pBuffer;
		}

		return *this;
	}
Esempio n. 10
0
void CppVariant::set(const NPVariant& newValue)
{
    freeData();
    switch (newValue.type) {
    case NPVariantType_Bool:
        set(newValue.value.boolValue);
        break;
    case NPVariantType_Int32:
        set(newValue.value.intValue);
        break;
    case NPVariantType_Double:
        set(newValue.value.doubleValue);
        break;
    case NPVariantType_String:
        set(newValue.value.stringValue);
        break;
    case NPVariantType_Null:
    case NPVariantType_Void:
        type = newValue.type;
        break;
    case NPVariantType_Object:
        set(newValue.value.objectValue);
        break;
    }
}
Esempio n. 11
0
void createTestSummary(char *baseFileName) {
    lineStruct **tests;
    uint numTests;
    tests = gatherTests(baseFileName, numTests);
    printTestsSummary(numTests, tests, baseFileName);
    freeData(tests, numTests);
}
Esempio n. 12
0
CFile::~CFile(){
	if(mStream){
        mStream->flush();
        delete mStream;
	}
	freeData();	
}
Esempio n. 13
0
int main(int argc, char **argv)
{
	exitCode = 0;

	initGtk(&argc, &argv);

	migrateConfigToXdgDir();
	migrateThemesToXdgDir();
	initDataDefault();

	if (parseCommandline(&argc, &argv)) {
		if(initLockFile()) {
			printMessage(MSG_INFO, "Startup %s %s (-h to print usage)\n", OBS_NAME, OBS_VERSION);
			if (initConfigs()) {
				initWidgets();
				gtk_widget_show_all(winWidget);
				gtk_main();
			}
			else
				exitCode = 1;
			deleteLockFile();
		}
		else
			exitCode = 1;
	}
	else
		exitCode = 1;

	freeData();

	exit(exitCode);
}
Esempio n. 14
0
Resources::~Resources() {
	// Free up any loaded data
	freeData();

	// Free up constant data
	_stringList.clear();
}
Esempio n. 15
0
File: tsp.c Progetto: Origraena/moca
int stratBranch (void *branchpoint, void **newbranch, size_t *size) {
	tsp_t *bp = (tsp_t *)branchpoint;
	*size = sizeof (tsp_t *);

	// Find number of children
	int *degre = (int *) calloc (bp->nb_node, sizeof (int)), i, j;
	for (i=0; i<bp->nb_node; i++) {
		degre[bp->sol[i]/bp->nb_node]++;
		degre[bp->sol[i]%bp->nb_node]++;
	}

	int max = 0, ind_max = 0;
	for (i=0; i<bp->nb_node; i++)
		if (degre[i] > max) {
			max = degre[i];
			ind_max = i;
		}

	if (max <= 2) {
		free (degre);
		return 0;
	}

	int *nodes = (int *) malloc (sizeof(int) * max);
	int zz = 0;
	for (i=0; i<bp->nb_node; i++) {
		if (bp->sol[i]/bp->nb_node == ind_max)
			nodes[zz++] = bp->sol[i]%bp->nb_node;
		else if (bp->sol[i]%bp->nb_node == ind_max)
			nodes[zz++] = bp->sol[i]/bp->nb_node;
	}

	tsp_t **nb = (tsp_t **) malloc (max * sizeof(tsp_t *));
	tsp_t *tmp;

	for (i=0; i< max; i++) {
		tmp = (tsp_t *) malloc (sizeof(tsp_t));
		tmp->nb_node = bp->nb_node;
		tmp->sol = (int *) malloc (bp->nb_node * sizeof(int));
		tmp->mat = (int **) malloc (sizeof(int*) *bp->nb_node);
		for (j=0; j<bp->nb_node; tmp->mat[j++] = (int *) malloc (sizeof(int)*bp->nb_node));
		copyData(tmp, bp);
		tmp->mat[nodes[i]][ind_max] = -1;
		tmp->mat[ind_max][nodes[i]] = -1;
		if (compPartSolFromACPM(tmp, 0)) 
			nb[i] = tmp;
		else {
			i--;
			max--;
			freeData(tmp);
		}
	}
	*newbranch = nb;
	free (degre);
	free(nodes);
	//	free(nb);

	return max;
}
Esempio n. 16
0
PagePositionHandler::~PagePositionHandler()
{
    XOJ_CHECK_TYPE(PagePositionHandler);

    freeData();

    XOJ_RELEASE_TYPE(PagePositionHandler);
}
Esempio n. 17
0
void mhwd::fillData(mhwd::Data *data) {
    freeData(data);

    fillDevices(data, mhwd::TYPE_PCI);
    fillDevices(data, mhwd::TYPE_USB);

    updateConfigData(data);
}
Esempio n. 18
0
void Bitmap::restoreState(SaveGame *state) {
	freeData();

	Common::String fname = state->readString();
	_data = BitmapData::getBitmapData(fname);

	_currImage = state->readLESint32();
}
Esempio n. 19
0
void CppVariant::set(const string& newValue)
{
    freeData();
    type = NPVariantType_String;
    NPString newString = {newValue.data(),
                          static_cast<uint32_t>(newValue.size())};
    WebBindings::initializeVariantWithStringCopy(this, &newString);
}
Esempio n. 20
0
void MemoryObject2::copyData(byte *src, int dataSize) {
	if (_data)
		freeData();

	_dataSize = dataSize;
	_data = (byte *)malloc(dataSize);

	memcpy(_data, src, _dataSize);
}
	int reset(AVFormatContext* formatCtx)
	{
		freeData();

		int result = av_read_frame(formatCtx, &packet);
		if (result < 0)
			packet.data = nullptr;
		return result;
	}
void SecureStorage_FreeStorage(void *s) {
  SecureStorageS *storage = NULL;

  if (s == NULL) return;
  storage = (SecureStorageS *)s;
  Utils_Free(storage->caSalt);
  Utils_Free(storage->caSecret);
  freeData(storage->Data);
}
Esempio n. 23
0
File: queue.c Progetto: Moumou38/ITD
void queue_delete(Queue* file)
{
	if(file == NULL)
		return;

	freeData(file->data);
	free(file);
	file = NULL;
}
Esempio n. 24
0
static int writeUnwrittenDiffs(){
	int status = updateDb(POLL_INTERVAL, unwrittenDiffs);
	
	logData(unwrittenDiffs);
	freeData(unwrittenDiffs);
	unwrittenDiffs = NULL;	
	
	return status;
}
        /**
         * Destructor.
         * Deletes allocated memory.
         */
        virtual ~DomainData()
        {
            if (loadingReference != NULL)
            {
                delete loadingReference;
                loadingReference = NULL;
            }

            freeData();
        }
Esempio n. 26
0
void Resources::reset() {
	freeData();

	_fieldList.reset();
	_barmanLists.reset();
	_talkState = TALK_NONE;
	_activeTalkData = NULL;

	reloadData();
}
Esempio n. 27
0
int main (int argc, char **argv) {
	tsp_t *t;
	void *sol;
	char *fil = "graph";

	if (argc == 2)
		fil = argv[1];

	FILE *in = fopen(fil, "r");
	initTSPFromFile(&t, in);
	fclose (in);

	allocMem(&sol, t);

	opt_t ord = MIN;
	strat_t str = DEPTH_FIRST;

	pb_t *p = initPb(lightestString, compCurVal, stratBranch, ord, t, copyData, freeData, str, acceptableSol, sizeof(tsp_t), initData, allocMem, printTSP);
	
	time_t cur = time(0);
	resolve_pb(p, sol);
	cur = time(0) - cur;
	
	int nbSommets = 0;
	in = fopen(fil, "r");
	fscanf(in, "%d",  &nbSommets);
	fclose(in);
	FILE *exec_time = fopen("tsp_bb_2opt.output", "a");
	fprintf(exec_time, "%d %d\n", nbSommets, cur);
	fclose(exec_time);

	if (acceptableSol(sol))
		printTSP((tsp_t*)sol);

	printf("Valeur solution : %d\n", compCurVal(sol));

	freePb(p);
	freeData(t);
	freeData(sol);
	return 0;
	
}
Esempio n. 28
0
int main(void)
{
	hashTable arrayHash[MAX];
	linkedData linkArray[MAX];

	initHashArray(arrayHash);
	storeFile(arrayHash,linkArray);
	freeData(arrayHash);

	return 0;
}
Esempio n. 29
0
bool GeoImage::testSize(int cols, int rows, IMGTYPE)
{
  if (cols != cols_ || rows != rows_) {
    qDebug("##  (ERROR) inconsistent image data!");
    // delete *data_;  // XXXX Fallunterscheidung dann löschen
    freeData();
    type_ = UNKNOWN;
    return FALSE;
  }
  return TRUE;
}
void ProfileDataContainer::rotateStorage() {
    // If we are mapped we want to stop using the ashmem backend and switch to malloc
    // We are expecting a switchStorageToAshmem call to follow this, but it's not guaranteed
    // If we aren't sitting on top of ashmem then just do a reset() as it's functionally
    // equivalent do a free, malloc, reset.
    if (mIsMapped) {
        freeData();
        mData = new ProfileData;
    }
    mData->reset();
}