Exemple #1
0
int a_haff(Byte* in_buf, int in_count, Byte* out_buf, int* out_count){
  for (int i = 0; i < in_count; i++){
    Reapets[in_buf[i]]++;
  }

  Root* R = malloc(byte_count * sizeof(Root*)), T = malloc(byte_count * sizeof(Root*)), t, t1, t2;
  int c_R = 0, c_T = 0;
  for (int i = 0; i < 256; i++){
    if (Reapets[i] != 0){
      R[c_R] = malloc(sizeof(Root));
      (*R[c_R]).left = NULL;
      (*R[c_R]).right = NULL;
      (*R[c_R]).reapet = Reapets[i];
      (*R[c_R]).value = i;
      c_R++;
    }
  }
  while (c_R + c_T > 1){
    t1 = GetMin(R, &c_R, T, &c_T);
    t2 = GetMin(R, &c_R, T, &c_T);
    t = malloc(sizeof(Root));
    (*t).left = t1;
    (*t).right = t2;
    (*t).reapet = (*t1).reapet + (*t2).reapeat;
    AddToArray(T, &c_T, t);
  }
}
Exemple #2
0
bool CMaterialLib::ProcessLine(char *p_pLine)
{
 char ch[2];
 //rf3 R3;
 rMaterial Mat;

 if(!p_pLine) return(false);

 ch[0] = *p_pLine;
 ch[1] = *(p_pLine + 1);
 switch(ch[0]) {
   case 'n':
     if(!strnicmp(p_pLine, "newmtl", 6)) {
       if(!ParseToStr(p_pLine, Mat.m_Name, sizeof(Mat.m_Name), true)) return(false);
       Mat.m_TextureID = 0;
       Mat.m_bTexture = false;
       memset(Mat.m_TextureFileName, 0, sizeof(Mat.m_TextureFileName));
       if(!AddToArray(MATERIALLIB_ARRTYPE_MATERIAL, &Mat)) return(false); }
     break;
   case 'm':
     if(!strnicmp(p_pLine, "map_Kd", 6))
       if(!Process_map_Kd(p_pLine + 6)) return(false);
     break;
   default:
     break;
   }
 return(true);
}
Exemple #3
0
/* Add an element to the array if it isn't already in the array. */
short AddUniqueToArray(Array *array, void *data)
{
    if (array != NULL) {
        /* Make sure the pointer is not already in the array. */
        if (!ExistsInArray(array, data)) {
            return AddToArray(array, data);
        }
    }
    return 0;
}
Exemple #4
0
int* GetAllFactors(int N, int* PtrSize)
{
	int i;
	DynArray DA;

	DA = Initialize(MAX);
	for (i = 2; i * i <= N; ++i)
	{
		if (IsPrime(i) == 1)
			AddToArray(DA, i);
	}

	*PtrSize = DA -> Size;
	return DA -> Next;
}
Exemple #5
0
int main()
{
	// Some data that we can play with
	char *names[4] = { "Steve", "Bill", "George", "fydo" };
	int numbers[4] = { 42, 33, 15, 74 };
	int i;
	
	// Populate!
	for (i = 0; i < 4; i++)
	{
		DATA temp;
		
		temp.name = malloc((strlen(names[i]) + 1) * sizeof(char));
		strncpy(temp.name, names[i], strlen(names[i]) + 1);
		temp.number = numbers[i];
		
		if (AddToArray(temp) == -1) // If there was a problem adding to the array,
			return 1;				// we'll want to bail out of the program. You
									// can handle it however you wish.
	}
	
	// Open a file and ...
	FILE *out;
	out = fopen("output.txt", "w");
	
	// Regurgitate!
	for (i = 0; i < 4; i++)
	{
		fprintf(out, "%s's number is %d!\n", the_array[i].name, the_array[i].number);
	}
	
	fprintf(out, "\n%d allocated, %d used\n", num_allocated, num_elements);
	
	fclose(out);
	
	// Deallocate!
	for (i = 0; i < 4; i++)
	{
		free(the_array[i].name);
	}

	free(the_array);	
	
	// All done.
	return 0;
}
Exemple #6
0
int  OGROSMLayer::AddFeature(OGRFeature* poFeature,
                             int bAttrFilterAlreadyEvaluated,
                             int* pbFilteredOut,
                             int bCheckFeatureThreshold)
{
    if( !bUserInterested )
    {
        if (pbFilteredOut)
            *pbFilteredOut = TRUE;
        delete poFeature;
        return TRUE;
    }

    OGRGeometry* poGeom = poFeature->GetGeometryRef();
    if (poGeom)
        poGeom->assignSpatialReference( poSRS );
    
    if( (m_poFilterGeom == NULL
        || FilterGeometry( poFeature->GetGeometryRef() ) )
        && (m_poAttrQuery == NULL || bAttrFilterAlreadyEvaluated
            || m_poAttrQuery->Evaluate( poFeature )) )
    {
        if (!AddToArray(poFeature, bCheckFeatureThreshold))
        {
            delete poFeature;
            return FALSE;
        }
    }
    else
    {
        if (pbFilteredOut)
            *pbFilteredOut = TRUE;
        delete poFeature;
        return TRUE;
    }
    
    if (pbFilteredOut)
        *pbFilteredOut = FALSE;
    return TRUE;
}
Exemple #7
0
SECStatus
CERT_AddAVA(PRArenaPool *arena, CERTRDN *rdn, CERTAVA *ava)
{
    rdn->avas = (CERTAVA**) AddToArray(arena, (void**) rdn->avas, ava);
    return rdn->avas ? SECSuccess : SECFailure;
}