Ejemplo n.º 1
0
double LocalCorrTrack(int pos1, int pos2, bool cmpl1, bool cmpl2, bool rnd){
	if(!outLC) return 0;
	if(smoothProf1==0) getMem(smoothProf1,profWithFlanksLength+10, "storeCorrTrack");
	if(lcTmp==0)       getMem(lcTmp,profWithFlanksLength+10, "storeCorrTrack");
	calcSmoothProfile(0, cmpl1);	// calculate smooth ptrofile c=\int f*\rho for the second profile (y)
	memcpy(smoothProf1,LCorrelation.re,profWithFlanksLength*sizeof(double));
	calcSmoothProfile(1, cmpl2);	// calculate smooth profile for the first profile (x)
	smoothProf2=LCorrelation.re;
	double av=0;

	double sd=track1->sd0*track2->sd0;
	for(int i=LFlankProfSize; i<profWithFlanksLength-RFlankProfSize; i++){
		double x=smoothProf1[i]	/profWithFlanksLength;					//the smoothed profile for x
		double y=smoothProf2[i]	/profWithFlanksLength;					//the smoothed profile for y
		double lc=0;													//local correlation
//		int ax=bTrack1.getBVal(pos1+i-LFlankProfSize,cmpl1);
//		int ay=bTrack2.getBVal(pos2+i-LFlankProfSize,cmpl2);
//		if(ax==NA || ay==NA) {lcTmp[i]=NA; continue;}
//		double x0=(ax==NA)?0: bTrack1.getVal(ax), y0=(ay==NA)?0: bTrack2.getVal(ay);
//		lc=0.5*(x0*y+y0*x);

		lc=x*y/sd;
		lc=normLC(lc);
		lcTmp[i]=lc; av+=lc;	    // We use wCorrelation.im as a tmp buffer
		dHist.add(lc,rnd ? 1:0);
	}
	av/=profileLength;
	if(!rnd) addLCProf(lcTmp,pos1);
	return av;
}
Ejemplo n.º 2
0
PUBLIC NET_StreamClass *
#endif

XML_XMLConverter(FO_Present_Types  format_out, void *data_object, URL_Struct *URL_s, MWContext  *window_id)
{
    NET_StreamClass* stream;
    XMLFile  xmlf;
    TRACEMSG(("Setting up display stream. Have URL: %s\n", URL_s->address));

    xmlf = (XMLFile) getMem(sizeof(XMLFileStruct));
    xmlf->holdOver = getMem(XML_BUF_SIZE);
    xmlf->lineSize = XML_LINE_SIZE;
    xmlf->line     = (char*)getMem(XML_LINE_SIZE);
    xmlf->urls = URL_s;
    xmlf->address = copyString(URL_s->address);
    xmlf->mwcontext = window_id;
    xmlf->numOpenStreams = 1;
	/*	URL_s->fedata = xmlf; */
    stream = NET_NewStream("XML", (MKStreamWriteFunc)parseNextXMLBlob, 
			   (MKStreamCompleteFunc)xml_complete,
			   (MKStreamAbortFunc)xml_abort, 
			   (MKStreamWriteReadyFunc)xml_write_ready, xmlf, window_id);
    if (stream == NULL) freeMem(xmlf);
	
    return(stream);
}
Ejemplo n.º 3
0
// Upload memory to the GPU
int uplMem(struct Interop* interop, int key, size_t memSize, float* data)
{
    size_t gpuSize;
    cl_mem gpu = getMem(*interop, key, &gpuSize);
    if (gpu)
    {
        // We just assume people know what they're doing if it's a screenbuffer.
        // This is probably a bad decision.
        if (gpuSize != 0 && gpuSize != memSize)
        {
            printf("Cannot upload memory: GPU was of size %lu while data was %lu\n",
                    gpuSize, memSize);
            return -1;
        }
    }
    else
    {
        printf("Allocating memory due to uplMem unknown buffer %d of size %lu\n",
                key, memSize);
        if (memSize == 0)
        {
            puts("Cannot allocate a zero-sized gpu array");
            return -1;
        }
        if (PrintErr(allocMem(interop, key, memSize, 0)))
            return -1;
        gpu = getMem(*interop, key, &gpuSize);
    }
    if (PrintErr(clEnqueueWriteBuffer(interop->command_queue, gpu, 1, 0, memSize, data,
            0, NULL, NULL)))
        return -1;
    return 0;
}
Ejemplo n.º 4
0
/* Returns the variable with the given name in the query.
   If not found:
   	if the query is running, return NULL
   	otherwise create a new variable with the given name.
   	if there isn't enough memory, return NULL.
*/
PR_PUBLIC_API(RDF_Variable) RDF_GetVariable(RDF_Query q, char* name) {
	RDF_Variable newvar;
	RDF_VariableList newlist;
	RDF_VariableList current = q->variables;
	while (current != NULL) {
		if (stringEquals(current->element->id, name)) return current->element;
		if (current->next == NULL) break;
		else current = current->next;
	}
	if (q->queryRunning) return NULL;
	newvar = (RDF_Variable)getMem(sizeof(RDF_VariableStruc));
	if (newvar == NULL) return NULL;
	newvar->id = copyString(name);
	newvar->query = q;
	/* create a list containing the variable and append it to the front of the variable list */
	newlist = (RDF_VariableList)getMem(sizeof(RDF_VariableListStruc));
	if (newlist == NULL) {
		freeMem(newvar);
		return NULL;
	}
	newlist->element = newvar;
	newlist->next = q->variables;
	q->variables = newlist;
	return newvar;
}
Ejemplo n.º 5
0
void CovarMtx::init(int nn){
	Matrix::init(nn);
	int n2=nn*nn;
	getMem(cov,	 n2,"covar1");	 zeroMem(cov,  n2);
	getMem(meani,n2,"covar2");   zeroMem(meani,n2);
	getMem(meanj,n2,"covar2");   zeroMem(meanj,n2);
	getMem(count,n2,"covar3"); 	 zeroMem(count,n2);
}
Ejemplo n.º 6
0
//62  bound reg,mem,mem
auto V30MZ::opBound() {
  wait(12);
  modRM();
  auto lo = getMem(Word, 0);
  auto hi = getMem(Word, 2);
  auto reg = getReg(Word);
  if(reg < lo || reg > hi) interrupt(5);
}
Ejemplo n.º 7
0
void preProcessReadsMT()
{
	_r_readIndexSize = getMem(sizeof(int)*THREAD_COUNT);
	_r_readIndex = getMem(sizeof(ReadIndexTable*)*THREAD_COUNT);

	_r_threads = getMem(sizeof(pthread_t)*THREAD_COUNT);
	int i=0; 
	for (i=0; i<THREAD_COUNT; i++)
		pthread_create(_r_threads+i, NULL, (void*)preProcessReads, THREAD_ID+i);
	
	for (i=0; i<THREAD_COUNT; i++)
		pthread_join(_r_threads[i], NULL);
	freeMem(_r_threads, sizeof(pthread_t)*THREAD_COUNT);	
}
Ejemplo n.º 8
0
void calculateSamplingLocations()
{
	int i;
	_r_samplingLocsSize = errThreshold + 1;
	_r_samplingLocs = getMem(sizeof(int)*(_r_samplingLocsSize+1));
	for (i=0; i<_r_samplingLocsSize; i++)
	{
		_r_samplingLocs[i] = (SEQ_LENGTH / _r_samplingLocsSize) *i;
		if ( _r_samplingLocs[i] + WINDOW_SIZE > SEQ_LENGTH)
			_r_samplingLocs[i] = SEQ_LENGTH - WINDOW_SIZE;
	}
	_r_samplingLocs[_r_samplingLocsSize]=SEQ_LENGTH;
	
	int size = sizeof(int)*_r_samplingLocsSize;
	_r_samplingLocsSeg = getMem(size);
	_r_samplingLocsOffset = getMem(size);
	_r_samplingLocsLen = getMem(size);
	_r_samplingLocsLenFull = getMem(size);
	for (i=0; i<_r_samplingLocsSize; i++)
	{
		_r_samplingLocsSeg[i]		= _r_samplingLocs[i] / (sizeof(CompressedSeq)*8/3);
		_r_samplingLocsOffset[i]	= _r_samplingLocs[i] % (sizeof(CompressedSeq)*8/3);
		_r_samplingLocsLen[i]		= _r_samplingLocs[i+1] - _r_samplingLocs[i];
		_r_samplingLocsLenFull[i]	= SEQ_LENGTH - _r_samplingLocs[i];
	}
	

	// Outputing the sampling locations
	/*int j;
 	for (i=0; i<SEQ_LENGTH; i++)
	{
		fprintf(stdout, "-");
	}
	fprintf(stdout, "\n");

	for ( i=0; i<_r_samplingLocsSize; i++ )
	{
		for ( j=0; j<_r_samplingLocs[i]; j++ )
			fprintf(stdout," ");
		for (j=0; j<WINDOW_SIZE; j++)
			fprintf(stdout,"+");
		fprintf(stdout, "\n");
		fflush(stdout);
	}
	for ( i=0; i<SEQ_LENGTH; i++ )
	{
		fprintf(stdout, "-");
	}
	fprintf(stdout, "\n"); */
}
Ejemplo n.º 9
0
void smooth(const char *fname){
	outLC=1;
	initOutLC();
	int l=profileLength;
	bTrack *tr=new bTrack(fname);

	for(int i=0,k=0; i<l; i+=wProfStep,k++){
		double d;
		d=100.*k/(l/wProfStep);
		if(k%10000 ==0) verb("\nSmooother: %4.1f%% (%6i/%i) ",d,k,l/wProfStep);
		else if(k%1000 ==0) verb(".");
		double *pr1=tr->getProfile(i,0);		// decode the first profile. Decoder uses hasCompl and complFg flags and combines profiles
		if(smoothProf==0) getMem(smoothProf,profWithFlanksLength+10, "storeCorrTrack");
		if(smTmp==0)      getMem(smTmp,profWithFlanksLength+10, "storeCorrTrack");
		kern->fftx(pr1,0);
		calcSmoothProfile(&(kern->fx),0, 0);	// calculate smooth ptrofile c=\int f*\rho
		addLCProf(LCorrelation.re,i);
	}
	char pfil[4096],wfil[4096];
	makeFileName(pfil,trackPath,fname);

	char *s=strrchr(pfil,'/'); if(s==0) s=wfil;
	s=strrchr(s,'.'); if(s) *s=0;
	sprintf(wfil,"%s_sm.bgr",pfil);

	//================ normalize
	double tt=0,ee=0,dd=0,nn=0;
	for(int i=0; i<l; i++) {
		double x=lcProfile->get(i);
		ee+=x; nn++; dd+=x*x;
	}
	tt=ee; ee/=nn; dd=dd/nn-ee*ee; dd=sqrt(dd);

	for(int i=0; i<l; i++) {
		double x=lcProfile->get(i);
		if(smoothZ){if((x-ee)/dd < smoothZ) x=0;}
		else	   {x=x*tr->total/tt/binSize;}
		lcProfile->set(i,x);
	}

	FILE *f=gopen(wfil,"w");
	char b[4096]; strcpy(b,fname);
	s=strrchr(b,'.'); if(s) *s=0;
	s=strchr(b,'/'); if(s==0) s=b;
	fprintf(f,"track type=bedGraph name=\"%s_Sm\" description=\"Smoothed track. Width=%.0f\"\n",s, kernelSigma);
	verb("\n Write Smooth profile...\n");
	writeBedGr(f,lcProfile, NA,  NA);
	verb("   Done\n");
}
Ejemplo n.º 10
0
void calcCovar(){
	int nIter=100;
	cMtx.init(nfiles);

	for(int i=0; i<nfiles; i++){
		for(int j=i; j<nfiles; j++){
			verb("Covariations %i~%i: <%s>~<%s> ",i,j,tracks[i]->name,tracks[j]->name);
			cMtx.calc(i,j);
		}
	}
	char b[2048];
	sprintf(b,"%s.cvr",confFile);
	FILE *f=xopen(b,"wt");
	cMtx.print(f);
	Matrix *x = new Matrix(&cMtx);
	getMem(eValues,nfiles+10,"eigenVal"); zeroMem(eValues,nfiles);
	eVectors=eigenVectors(x,eValues,nIter,1.E-3);
	fputs("eigenVectors\n",f);
	eVectors->printMtx(f);
	fputs("eigenValues\n",f);
	for(int i=0; i<nfiles; i++)
		fprintf(f,"%.5f; ",eValues[i]);
	fprintf(f,"\n");
	fclose(f);
	del(x);
}
Ejemplo n.º 11
0
RDF_Resource
HistCreate (char* url, PRBool createp)
{
  size_t size = strlen(url);
  char* nurl = getMem(size+8);
  RDF_Resource ans;
  if (charSearch(':', url) == -1) {    
    if (url[size-1] == '/') {
      sprintf(nurl, "http://%s", url);
      nurl[strlen(nurl)-1] = '\0';
    } else {
    sprintf(nurl, "http://%s/", url);
    }
  } else {
    if (url[size-1] == '/') {
      memcpy(nurl, url, size-1);
    } else {
      sprintf(nurl, "%s/", url);
    }
  }
  ans = RDF_GetResource(NULL, nurl, 0);
  if (ans != NULL) {
    freeMem(nurl);
    return ans;
  } 
  freeMem(nurl);
  ans = RDF_GetResource(NULL, url, createp);

  if (ans != NULL) {
    return ans;
  } else {
    return NULL;
  }
}
Ejemplo n.º 12
0
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctRRV(RDF_Query q, RDF_Resource arg1, RDF_Resource s, RDF_Variable arg2, RDF_ValueType type) {
	RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
	if (literal == NULL) return RDF_NO_MEMORY;
	literal->u.value = arg1;
	literal->u.type = RDF_RESOURCE_TERM_TYPE;
	literal->s = s;
	literal->valueCount = 1;
	literal->v = (TermStruc*)getMem(sizeof(TermStruc));
	literal->v->value = (void*)arg2;
	literal->v->type = RDF_VARIABLE_TERM_TYPE;
	((RDF_Variable)literal->v->value)->type = literal->valueType = type;
	literal->tv = true;
	addLiteral(q, literal);	
	q->conjunctsOrdered = false;
	return noRDFErr;
}
Ejemplo n.º 13
0
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctRRO(RDF_Query q, RDF_Resource arg1, RDF_Resource s, void* arg2, RDF_ValueType type) {
	RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
	if (literal == NULL) return RDF_NO_MEMORY;
	literal->u.value = (void*)arg1;
	literal->u.type = RDF_RESOURCE_TERM_TYPE;
	literal->s = s;
	literal->valueCount = 1;
	literal->v = (TermStruc*)getMem(sizeof(TermStruc));
	literal->v->value = (type == RDF_STRING_TYPE) ? (void*)copyString((char*)arg2) : (void*)arg2;
	literal->v->type = RDF_CONSTANT_TERM_TYPE;
	literal->valueType = type;
	literal->tv = true;
	addLiteral(q, literal);	
	q->conjunctsOrdered = false;		
	return noRDFErr;
}
Ejemplo n.º 14
0
RDFT
MakeMailAccountDB (char* url)
{
  if (startsWith("mailaccount://", url)) {
    RDFT   ntr =   NewRemoteStore(url);
    char*  fileurl = getMem(100);
    int32 n = PR_SKIP_BOTH;
    PRDirEntry	*de;
    PRDir* dir ;
    RDF_Resource top = RDF_GetResource(NULL, url, 1);
    sprintf(fileurl, "%s%s", profileDirURL, &url[14]);
    dir = OpenDir(fileurl);
    if (dir == NULL) {
      if ( CallPRMkDirUsingFileURL(fileurl, 00700) > -1) dir = OpenDir(fileurl);
    }
    while ((dir != NULL) && ((de = PR_ReadDir(dir, (PRDirFlags)(n++))) != NULL)) {
      if ((!endsWith(".ssf", de->name)) && (!endsWith(".dat", de->name)) && 
          (!endsWith(".snm", de->name)) && (!endsWith("~", de->name))) {
        RDF_Resource r;
        sprintf(fileurl, "mailbox://folder/%s/%s", &url[14], de->name);
        r = RDF_GetResource(NULL, fileurl, 1);
        setResourceType(r, PMF_RT);
        remoteStoreAdd(ntr, r, gCoreVocab->RDF_parent, top, RDF_RESOURCE_TYPE, 1);
        remoteStoreAdd(ntr, r, gCoreVocab->RDF_name, copyString(de->name), RDF_STRING_TYPE, 1);
      }
    }
    freeMem(fileurl);
    if (dir) PR_CloseDir(dir);
    return ntr;
  } else return NULL;
}
Ejemplo n.º 15
0
RDF_Error
parseSlotValue (RDFFile f, RDF_Resource s, char* value, void** parsed_value, RDF_ValueType* data_type)
{
  if (value[0] == '"') {
    int32 size = strlen(value)-1;
    *parsed_value = getMem(size);
    value[size]  = '\0';
    *parsed_value = &value[1];
    *data_type = RDF_STRING_TYPE;
    return noRDFErr;
  } else if (value[0] == '#') {
    if (value[1] == '"') {
      value[strlen(value)-1] = '\0';
      value = &value[2];
    } else {
      value = &value[1];
    }
    *parsed_value = resolveReference(value, f);
    return noRDFErr;
  } else if (charSearch('.', value) == -1) {
    int16 ans = 0;
    /* XXX		sscanf(value, "%ld", &ans); */
    *data_type = RDF_INT_TYPE;
    return noRDFErr;
  } else {
    return -1;
  }
}
Ejemplo n.º 16
0
static char * text2char(text *in) {
  	char *out = (char *)getMem(VARSIZE(in));

  	memcpy(out, VARDATA(in), VARSIZE(in) - VARHDRSZ);
  	out[VARSIZE(in) - VARHDRSZ] = '\0';
  	return out;
}
Ejemplo n.º 17
0
// Inicializa los writers, recibe cantidad de writers, tiempo de escritura,
// tiempo de descanso, la llave del segmento al que va a escribir y el tipo
// de proceso
void initProcesos(int cantidadProcesos,int tiempoEscritura,int tiempoDescanso,int llave,int tipo){
	int i,segmentoDatosID;
	char *segmentoDatos;
	// Monitor
	switch(tipo){
		case TIPO_WRITER:
			segmentoDatosID = getMemID(LLAVE_SEGMENTO_WRITERS,cantidadProcesos*TAMANIO_LINEAS);
			break;
		case TIPO_READER:
			segmentoDatosID = getMemID(LLAVE_SEGMENTO_READERS,cantidadProcesos*TAMANIO_LINEAS);
			break;
		case TIPO_READER_EGOISTA:
			segmentoDatosID = getMemID(LLAVE_SEGMENTO_READERS_EGOISTAS,cantidadProcesos*TAMANIO_LINEAS);
			break;
		default:
			break;
		}
	segmentoDatos = getMem(segmentoDatosID);
	crearMemoria(llave,cantidadProcesos);
	pthread_t processThread[cantidadProcesos];
	for(i=1;i<=cantidadProcesos;i++){
		proceso *nProcess = newProcess(i,tiempoEscritura,tiempoDescanso,tipo,segmentoDatos);
		pthread_create(&processThread[i-1], NULL, ejecutarProceso, nProcess);
	}
	for(i=0;i<cantidadProcesos;i++){
		pthread_join(processThread[i], NULL);
	}
}
Ejemplo n.º 18
0
/*
 * trySwap - try to swap an fcb
 */
static void *trySwap( size_t size, int upper_bound, WHO_PTR who )
{
    void        *tmp = NULL;
    fcb         *tfcb;

    for( ;; ) {

        /*
         * find LRU fcb
         */
        tfcb = getLRU( upper_bound );
        if( tfcb == NULL ) {
            break;
        }

        /*
         * swap the LRU fcb, and re-attempt allocation
         */
        SwapFcb( tfcb );
        tmp = getMem( size, who );
        if( tmp != NULL ) {
            break;
        }

    }

    return( tmp );

} /* trySwap */
Ejemplo n.º 19
0
int GFFFile::endwrite(uint8 **mem, uint32 *size)
{
	if((datas.size() != datac.size()) || (datas.size() != dataoffs.size()) ||
	   (datas.size() != datasizes.size()))
		return errcode = 25;
	for(uint32 i=0;i<structs.size();i++)
	{
		if((structs[i].fieldcount = structs[i].values.size()) > 1)
			fieldidxsize += structs[i].fieldcount*4;
		// Yeah, I know this is kind of a bad hack, but I need it that way...
		for(uint32 j=0;j<structs[i].labels.size();j++)
			if(structs[i].labels[j] == (std::string *) -1)
				structs[i].labels[j] = (std::string *) (uint64) addLabel("");
	}
	for(uint32 i=0;i<lists.size();i++)
		listidxsize += lists[i].size()*4 + 4;
	structcount = structs.size();
	labelcount = labels.size();
	offstruct = 56;
	offfield = offstruct + structcount*12;
	offlabel = offfield + fieldcount*12;
	offfielddata = offlabel + labelcount*16;
	offfieldidx = offfielddata + fielddatasize;
	offlistidx = offfieldidx + fieldidxsize;

	if(finalWriteHeader()) return errcode;
	if(finalWriteData()) return errcode;
	if(finalWriteLists()) return errcode;
	if(finalWriteLabels()) return errcode;
	if(finalWriteStructs()) return errcode;
	deInit();
	if(mem) *mem = getMem();
	if(size) *size = getMemSize();
	return 0;
}
Ejemplo n.º 20
0
RDF_Resource
resolveReference (char *tok, RDFFile f)
{
  RDF_Resource existing;
  char* url = getMem(MAX_URL_SIZE);
  if (tok[0] == '#') tok = &tok[1];
  if (tok[strlen(tok)-1] == '"') tok[strlen(tok)-1] = '\0';
  if (tok[0] == '"') tok = &tok[1];
  memset(url, '\0', 200);
  if (charSearch(':', tok) == -1) { 
    derelativizeURL(tok, url, f);
  } else {
    memcpy(url, tok, strlen(tok));
  }
  if (strcmp(url,"this") == 0) {
    existing = f->top;
  } else {
    existing = RDF_GetResource(NULL, url, false);
  }
  if (existing != null) return existing;
  existing = RDF_GetResource(NULL, url, true);
  addToResourceList(f, existing);
  freeMem(url);
  return existing;
}
Ejemplo n.º 21
0
/* Double length of the array of pointers when append() needs to go past current limit */
void growPtrList(SB *sb) {
	size_t nBytes = 2 * sb->capacity * sizeof(char *);
	char **pTemp = (char **) getMem(nBytes);
	memcpy((void *) pTemp, (void *) sb->ptrList, sb->capacity * sizeof(char *));
	sb->capacity *= 2;
	free(sb->ptrList);
	sb->ptrList = pTemp;
}
Ejemplo n.º 22
0
/* Initialize a new StringBuffer structure */
void init(SB *sb) {
	sb->count = 0;
	sb->capacity = STR_BUF_INIT_SIZE;
	sb->ptrList = (char **) getMem( STR_BUF_INIT_SIZE * sizeof(char *));
	sb->append = append;
	sb->toString = toString;
	sb->dispose = dispose;
}
Ejemplo n.º 23
0
/* Adds a literal to the query. */
void addLiteral(RDF_Query q, RDF_Literal literal) {
	RDF_LiteralList newlist = (RDF_LiteralList)getMem(sizeof(RDF_LiteralListStruc));
	if (newlist == NULL) return;
	newlist->element = literal;
	newlist->next = q->literals;
	q->literals = newlist;
	q->numLiterals++;
}
Ejemplo n.º 24
0
auto V30MZ::opExchangeMemReg(Size size) {
  wait(2);
  modRM();
  auto mem = getMem(size);
  auto reg = getReg(size);
  setMem(size, reg);
  setReg(size, mem);
}
Ejemplo n.º 25
0
void 
RDF_StartMessageDelivery (RDFT rdf)
{
  MF folder = (MF) rdf->pdata;
  MM msg    = (MM) getMem(sizeof(struct MailMessage));
  char* nurl = getMem(100);
  fseek(folder->mfile, 0L, SEEK_END);
  fprintf(folder->mfile, "From - \n");
  msg->offset = ftell(folder->mfile);
  sprintf(nurl, "%s?%i", rdf->url, msg->offset);
  msg->r = RDF_GetResource(NULL, nurl, 1);
  msg->r->pdata = msg;
  msg->flags = getMem(4);
  folder->add = msg;
  setResourceType(msg->r, PM_RT); 
  fseek(folder->mfile, 0L, SEEK_END);
  fputs("X-Mozilla-Status: 0000\n", folder->mfile);
}
Ejemplo n.º 26
0
int TLKFile::write(uint8 **mem, uint32 *size)
{
	if(openWrite()) return errcode;
	if(finalWrite()) return errcode;
	if(mem) *mem = getMem();
	if(size) *size = getMemSize();
	close();
	return errcode = 0;
}
Ejemplo n.º 27
0
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
int NvBufDrv::getBuf(CAMERA_DATA_TYPE_ENUM nvRamId, int sensorDev, void*& p)
{
    DEF_AutoLock(m_cs);
    int err;
    err = readNoLock(nvRamId, sensorDev);
    if(err != 0)
        return err;
    return getMem(nvRamId, (CAMERA_DUAL_CAMERA_SENSOR_ENUM)sensorDev, p);
}
Ejemplo n.º 28
0
void
initRDFFile (RDFFile ans)
{
  char* url = ans->url;
  ans->rtop = getMCFFrtop(url);
  ans->line = (char*)getMem(RDF_BUF_SIZE);
  ans->currentSlot = (char*)getMem(100);
  ans->resourceList = (RDF_Resource*)getMem(200);
  ans->assertionList = (Assertion*)getMem(400);
  ans->resourceListSize = 50;
  ans->assertionListSize = 100;
  ans->holdOver = (char*)getMem(RDF_BUF_SIZE);
  ans->depth = 1;
  ans->lastItem = ans->stack[0] = ans->top;
  ans->locked = ans->localp;
  ans->lineSize = LINE_SIZE;
  ans->tv = true;
}
Ejemplo n.º 29
0
/*
 * doMemAllocUnsafe - see above
 */
static void *doMemAllocUnsafe( size_t size, WHO_PTR who )
{
    void        *tmp;

    tmp = getMem( size, who );
    if( tmp == NULL ) {
        tossBoundData();
        tmp = trySwap( size, 1, who );
        if( tmp == NULL ) {
            SwapAllWindows();
            while( (tmp = getMem( size, who )) == NULL ) {
                if( !TossUndos() ) {
                    return( NULL );
                }
            }
        }
    }
    return( tmp );
}
Ejemplo n.º 30
0
char *
append2Strings (const char* str1, const char* str2)
{
  int32 l1 = strlen(str1);
  int32 len = l1 + strlen(str2);
  char* ans = (char*) getMem(len+1);
  memcpy(ans, str1, l1);
  memcpy(&ans[l1], str2, len-l1);
  return ans;
}