Beispiel #1
0
void
CIDFont_release (CIDFont *font)
{
  if (font) {
    if (font->indirect)
      ERROR("%s: Object not flushed.", CIDFONT_DEBUG_STR);
    if (font->fontdict)
      ERROR("%s: Object not flushed.", CIDFONT_DEBUG_STR);
    if (font->descriptor)
      ERROR("%s: Object not flushed.", CIDFONT_DEBUG_STR);

    if (font->fontname) RELEASE(font->fontname);
    if (font->name)     RELEASE(font->name);
    if (font->ident)    RELEASE(font->ident);
    if (font->csi) {
      if (font->csi->registry)
	RELEASE(font->csi->registry);
      if (font->csi->ordering)
	RELEASE(font->csi->ordering);
      RELEASE(font->csi);
    }
    if (font->options)
      release_opt(font->options);
  }
}
/**
* @brief get best satisfaction solution of optimal matrix use recursion.
*
* @param V volume array of different type of drinks.
* @param C constraints of drinks.
* @param H satisfactions of drinks.
* @param B the actual purchase amount of drinks.
* @param size size of drinks.
* @param totalV total volume.
*
* @return return best satisfaction, but not any actual purchase amount result.
*/
int best_satisfaction_solution_use_recursion(int* V, int* C, int* H, int* B, 
	int size, int totalV) {
	int** opt = init_opt(totalV, size);
	best_satisfaction_solution_recursion(V, C, H, B, size, totalV, opt, totalV,
		0);
	int best_satisfaction = opt[totalV][0];
	release_opt(opt, totalV);
	return best_satisfaction;
}
Beispiel #3
0
static char *palloc(int *sizepos,int size,int *indxpos,BLK **blk)
/*
 * main allocation routine
 */
{
  BLK      *bp;
  char            *rv;
	if( size & 1 )		/* if odd size */
		size += 1;	/* make it even */
	/* if anything left, try to allocate from it */
  if( *sizepos >= size ) {
    rv = &((*blk)->m[*indxpos]);
    *sizepos -= size;
    *indxpos += size;
    return rv;
  }
  else    {
		long allocsize;
		/* else check for size > normal blcok size */
		if (size > 2048) {
			/* this is going to fragment memory!!! I'd fix it except
			 * the fragmentation is partially dependent on the calloc 
			 * implementation 
			 */
			allocsize = size - 1;
			*sizepos = 0;
		}
		else {
			/* as long as we stick to normal blocks, fragmentation
			 * won't be an issue because as long as all blocks are the
			 * same size calloc is guaranteed to find one if there are any
			 */
			allocsize = 2047;
			*sizepos = 2048 - size;
		}
		/* allocate mem */
    bp = calloc(1,sizeof(BLK) + allocsize);
		if( bp == NULL ) {
			release_global();
			release_local();
			release_opt();
			release_oc();
			mem_summary();
			fatal(" not enough memory.");
		}
		bp->blksize = allocsize;
		/* link the block and return the base */
    bp->next = *blk;
    *blk = bp;
    *indxpos = size;
    return (*blk)->m;
	}
}
Beispiel #4
0
static void
release_comp (gpgme_conf_comp_t comp)
{
  gpgme_conf_opt_t opt;

  if (comp->name)
    free (comp->name);
  if (comp->description)
    free (comp->description);
  if (comp->program_name)
    free (comp->program_name);

  opt = comp->options;
  while (opt)
    {
      gpgme_conf_opt_t next = opt->next;
      release_opt (opt);
      opt = next;
    }

  free (comp);
}
/**
* @brief get best satisfaction solution of optimal matrix.
*
* @param V volume array of different type of drinks.
* @param C constraints of drinks.
* @param H satisfactions of drinks.
* @param B the actual purchase amount of drinks.
* @param size size of drinks.
* @param totalV total volume.
*
* @return return best satisfaction, but not any actual purchase amount result.
*/
int best_satisfaction_solution(int* V, int* C, int* H, int* B, int size, 
	int totalV) {
	int** opt = init_opt(totalV, size);
	int v = 0, i = 0, k = 0;
	for (v = 0; v <= totalV; v ++) {
		for (i = size-1; i >= 0; i --) {
			for (k = 0; k <= C[i]; k ++) {
				if (v < V[i]*k) { break; }
				int x = opt[v-V[i]*k][i+1];
				if (INT32_MIN != x) {
					x += H[i]*k;
					if (x > opt[v][i]) {
						opt[v][i] = x;
					}
				}
			}
		}
	}

	int best_satisfaction = opt[totalV][0];
	release_opt(opt, totalV);
	return best_satisfaction;
}