/*
** Find a VFile by name.  Create it if it does not already exist and
** initialize it to the size and content given.
**
** Return NULL only if the filesystem is full.
*/
static VFile *createVFile(const char *zName, int sz, unsigned char *pData){
  VFile *pNew = findVFile(zName);
  int i;
  if( pNew ) return pNew;
  for(i=0; i<MX_FILE && g.aFile[i].sz>=0; i++){}
  if( i>=MX_FILE ) return 0;
  pNew = &g.aFile[i];
  if( zName ){
    pNew->zFilename = safe_realloc(0, strlen(zName)+1);
    memcpy(pNew->zFilename, zName, strlen(zName)+1);
  }else{
    pNew->zFilename = 0;
  }
  pNew->nRef = 0;
  pNew->sz = sz;
  pNew->a = safe_realloc(0, sz);
  if( sz>0 ) memcpy(pNew->a, pData, sz);
  return pNew;
}
Example #2
0
/*
 * Check whether there's room for one more clause in rule_inst_table.
 * - if not, make the table larger
 */
void rule_inst_table_resize(rule_inst_table_t *rule_inst_table){
	int32_t size = rule_inst_table->size;
	int32_t num_rinsts = rule_inst_table->num_rule_insts;
	if (num_rinsts + 1 < size) return;
	if (MAXSIZE(sizeof(rule_inst_t *), 0) - size <= (size/2)){
		out_of_memory();
	}
	size += size/2;
	rule_inst_table->rule_insts = (rule_inst_t **) safe_realloc(
			rule_inst_table->rule_insts, size * sizeof(rule_inst_t *));
	rule_inst_table->assignment = (samp_truth_value_t *) safe_realloc(
			rule_inst_table->assignment, size * sizeof(samp_truth_value_t));
	rule_inst_table->rule_watched = (samp_clause_list_t *) safe_realloc(
			rule_inst_table->rule_watched, size * sizeof(samp_clause_list_t));
	rule_inst_table->size = size; 
	//if (MAXSIZE(sizeof(samp_clause_t *), sizeof(rule_inst_t)) < num_clauses) {
	//	out_of_memory();
	//}
}
Example #3
0
static int array_remove_i(struct array *a,int fr) {
  if(!a->n) { return 0; }
  a->n--;
  if(fr && a->freev)
    a->freev(a->e[a->n],a->freevp);
  if(a->n*4 < a->N && a->N>=16) {
    a->N /= 2;
    a->e = safe_realloc(a->e,sizeof(void*)*a->N);
  }
  return 1;
}
Example #4
0
/*
 * Make room for more equalities
 */
static void extend_equality_queue(equality_queue_t *queue) {
  uint32_t n;

  n = 2 * queue->qsize;
  if (n > MAX_QSIZE) {
    out_of_memory();
  }

  queue->data = (equality_t *) safe_realloc(queue->data, n * sizeof(equality_t));
  queue->qsize = n;
}
Example #5
0
/*
 * Increate the heap size by 50%
 */
static void extend_int_heap2(int_heap2_t *heap) {
  uint32_t n;

  n = heap->size + 1;
  n += n>>1;
  if (n >= MAX_INT_HEAP2_SIZE) {
    out_of_memory();
  }
  heap->heap = (int32_t *) safe_realloc(heap->heap, n * sizeof(int32_t));
  heap->size = n;
}
Example #6
0
/*
 * Increate the heap size by 50%
 */
static void extend_ptr_heap(ptr_heap_t *heap) {
  uint32_t n;

  n = heap->size + 1;
  n += n>>1;
  if (n >= MAX_PTR_HEAP_SIZE) {
    out_of_memory();
  }
  heap->heap = (void **) safe_realloc(heap->heap, n * sizeof(void *));
  heap->size = n;
}
Example #7
0
/*
 * Increase the heap array size by 50%
 */
static void increase_generic_heap(generic_heap_t *heap) {
  uint32_t n;

  n = heap->size + 1;
  n += n>>1;
  if (n >= MAX_GENERIC_HEAP_SIZE) {
    out_of_memory();
  }
  heap->heap = (int32_t *) safe_realloc(heap->heap, n * sizeof(int32_t));
  heap->size = n;
}
Example #8
0
void
local_retune(MHEGBackend *t, OctetString *service)
{
	unsigned int service_id;
	char service_str[64];
	char *slash;
	int prefix_len;

	/* assert */
	if(service->size < 6 || strncmp((char *) service->data, "dvb://", 6) != 0)
		fatal("local_retune: unable to tune to '%.*s'", service->size, service->data);

	/* extract the service_id */
	service_id = si_get_service_id(service);
	snprintf(service_str, sizeof(service_str), "%u", service_id);

	/*
	 * base_dir is: [path/to/services/]<service_id>
	 * so we just need to replace the last filename component with the new service_id
	 */
	slash = strrchr(t->base_dir, '/');
	if(slash == NULL)
	{
		/* no preceeding path */
		t->base_dir = safe_realloc(t->base_dir, strlen(service_str) + 1);
		strcpy(t->base_dir, service_str);
	}
	else
	{
		prefix_len = (slash - t->base_dir) + 1;
		t->base_dir = safe_realloc(t->base_dir, prefix_len + strlen(service_str) + 1);
		strcpy(t->base_dir + prefix_len, service_str);
	}

	/* update rec://svc/def */
	local_set_service_url(t);

	verbose("Retune: new service gateway is '%s'", t->base_dir);

	return;
}
Example #9
0
/* The expected input file is the result of anathons analysis */
int get_data(char *inFileName, Dat *dat){

	FILE *inFile = 0; /* input file */
	char line[80]; /* line */
	unsigned int allocated = 64; /* allocation counter */
    pcre *re; /* regular expression */
    const char *error; /* error message string */
	int erroffset; /* error offset */
    int ovector[OVECCOUNT]; /* match vector */
    int rc; /* match return value */
    char **substring_list; /* substring list */

	/* initialise/allocate memory for set of (64) frag entries */
    dat->nData = 0;
	dat->data = safe_malloc(allocated * sizeof(Ang));

	/* read data */
	inFile = safe_open(inFileName, "r");

	/* compile regexp */
    re = pcre_compile("^.{7}\t.{4}\t.{6}\t(........)\t(........)\t(........)", 0, &error, &erroffset, NULL);

    /* count the number of models */
    while(fgets(line, 80, inFile) != NULL )
    {
        rc = pcre_exec(re, NULL, line, strlen(line), 0, 0, ovector, OVECCOUNT);
        if (rc == 4){
            pcre_get_substring_list(line, ovector, rc, (const char ***)&substring_list);
            dat->data[dat->nData].phi1   = atof(substring_list[1]);
            dat->data[dat->nData].phi2   = atof(substring_list[2]);
            dat->data[dat->nData].theta  = atof(substring_list[3]);
            ++dat->nData;

            /* free substring_list memory */
            pcre_free_substring_list((const char **)substring_list);
        }

		/* allocate more memory if needed */
		if (dat->nData == allocated) {
			allocated += 64;
			dat->data = safe_realloc(dat->data, allocated * sizeof(Ang));
		}
    }

	/* free regexp */
    pcre_free(re);

	assert(dat->nData > 1);

    /* close file handle */
	fclose(inFile);
	return 0;
}
Example #10
0
/*
 * Increase the stack size (by 50%)
 */
static void extend_pp_stack(pp_stack_t *stack) {
  uint32_t n;

  n = stack->size + 1;
  n += n>>1;
  if (n >= MAX_PP_STACK_SIZE) {
    out_of_memory();
  }

  stack->data = (pp_state_t *) safe_realloc(stack->data, n * sizeof(pp_state_t));
  stack->size = n;
}
Example #11
0
static int heap_grow(gh_heap_t *heap) {
  int newsize;

  /* Do we really need to grow? */
  assert(heap->count == heap->highwm);

  newsize = heap->count + GH_SLOTS;
  heap->slots = (gh_hnode_t **)safe_realloc(heap->slots,
                                            newsize * sizeof(gh_hnode_t *));
  heap->highwm += GH_SLOTS;
  return 0;
}
Example #12
0
static void append_str_item(char **str, const char *item, int sep)
{
    char *p;
    size_t sz = strlen(item);
    size_t ssz = *str ? strlen(*str) : 0;

    safe_realloc(str, ssz + (ssz && sep ? 1 : 0) + sz + 1);
    p = *str + ssz;
    if (sep && ssz)
        *p++ = sep;
    memcpy(p, item, sz + 1);
}
Example #13
0
/*
 * Make map 50% larger
 */
static void extend_map(map_t *map) {
  uint32_t n;

  n = map->size + 1;
  n += n>>1;
  if (n >= MAX_MAP_SIZE) {
    out_of_memory();
  }

  map->data = (map_elem_t *) safe_realloc(map->data, n * sizeof(map_elem_t));
  map->size = n;
}
Example #14
0
void query_instance_table_resize(query_instance_table_t *table) {
	int32_t size = table->size;
	int32_t num_queries = table->num_queries;
	if (num_queries + 1 < size) return;
	if (MAXSIZE(sizeof(samp_query_instance_t *), 0) - size <= (size/2)) {
		out_of_memory();
	}
	size += size/2;
	table->query_inst = (samp_query_instance_t **)
		safe_realloc(table->query_inst, size * sizeof(samp_query_instance_t *));
	table->size = size; 
}
Example #15
0
static void pred_tbl_resize(pred_tbl_t *pred_tbl){//call this extend, not resize
	int32_t size = pred_tbl->size;
	int32_t num_preds = pred_tbl->num_preds;
	if (num_preds < size) return;
	if (MAXSIZE(sizeof(pred_entry_t), 0) - size <= (size/2)){
		out_of_memory();
	}
	size += size/2;
	pred_tbl->entries = (pred_entry_t *) safe_realloc(pred_tbl->entries,
			size * sizeof(pred_entry_t));
	pred_tbl->size = size; 
}
Example #16
0
MemBlock BigHeap::resizeBig(void* ptr, size_t newsize) {
  // Since we don't know how big it is (i.e. how much data we should memcpy),
  // we have no choice but to ask malloc to realloc for us.
  auto const n = static_cast<BigNode*>(ptr) - 1;
  auto const newNode = static_cast<BigNode*>(
    safe_realloc(n, newsize + sizeof(BigNode))
  );
  if (newNode != n) {
    m_bigs[newNode->index] = newNode;
  }
  return {newNode + 1, newsize};
}
Example #17
0
void source_table_extend(source_table_t *table) {
	int32_t size = table->size;
	int32_t num_entries = table->num_entries;
	if (num_entries + 1 < size) return;
	if (MAXSIZE(sizeof(source_entry_t *), 0) - size <= (size/2)) {
		out_of_memory();
	}
	size += size/2;
	table->entry = (source_entry_t **)
		safe_realloc(table->entry, size * sizeof(source_entry_t *));
	table->size = size; 
}
Example #18
0
static void mix_add_entry (REMAILER ***type2_list, REMAILER *entry,
			   size_t *slots, size_t *used)
{
  if (*used == *slots)
  {
    *slots += 5;
    safe_realloc (type2_list, sizeof (REMAILER *) * (*slots));
  }
  
  (*type2_list)[(*used)++] = entry;
  if (entry) entry->num = *used;
}
Example #19
0
/* Read a line from ``fp'' into the dynamically allocated ``s'',
 * increasing ``s'' if necessary. The ending "\n" or "\r\n" is removed.
 * If a line ends with "\", this char and the linefeed is removed,
 * and the next line is read too.
 */
char *mutt_read_line (char *s, size_t *size, FILE *fp, int *line)
{
  size_t offset = 0;
  char *ch;

  if (!s)
  {
    s = safe_malloc (STRING);
    *size = STRING;
  }

  FOREVER
  {
    if (fgets (s + offset, *size - offset, fp) == NULL)
    {
      safe_free (&s);
      return NULL;
    }
    if ((ch = strchr (s + offset, '\n')) != NULL)
    {
      (*line)++;
      *ch = 0;
      if (ch > s && *(ch - 1) == '\r')
	*--ch = 0;
      if (ch == s || *(ch - 1) != '\\')
	return s;
      offset = ch - s - 1;
    }
    else
    {
      int c;
      c = getc (fp); /* This is kind of a hack. We want to know if the
                        char at the current point in the input stream is EOF.
                        feof() will only tell us if we've already hit EOF, not
                        if the next character is EOF. So, we need to read in
                        the next character and manually check if it is EOF. */
      if (c == EOF)
      {
        /* The last line of fp isn't \n terminated */
        (*line)++;
        return s;
      }
      else
      {
        ungetc (c, fp); /* undo our dammage */
        /* There wasn't room for the line -- increase ``s'' */
        offset = *size - 1; /* overwrite the terminating 0 */
        *size += STRING;
        safe_realloc (&s, *size);
      }
    }
  }
}
void mutt_ungetch (int ch, int op)
{
  event_t tmp;

  tmp.ch = ch;
  tmp.op = op;

  if (UngetCount >= UngetBufLen)
    safe_realloc ((void **) &KeyEvent, (UngetBufLen += 128) * sizeof(event_t));

  KeyEvent[UngetCount++] = tmp;
}
/* Transmutes the internal data buffer into the structured output
 * which may be retured to the client.
 */
int log_outputs(output_buffer *ob, unsigned int modelid) {
  unsigned int outputid, nquantities, dataid, quantityid;
  output_t *out;
  double *odata;

  unsigned int modelid_offset = ob->modelid_offset[modelid];
  unsigned int ndata = ob->count[modelid];
  output_buffer_data *buf = (output_buffer_data *)(ob->buffer + (modelid * BUFFER_LEN * collection_status.precision));
	     
  for (dataid = 0; dataid < ndata; ++dataid) {
    outputid = buf->outputid;
    assert(collection_status.num_outputs > outputid);

    nquantities = buf->num_quantities;
    assert(collection_status.output_num_quantities[outputid] == nquantities);

    if (outputid > collection_status.num_outputs) { return LOG_OUTPUTS_CORRUPT; }
    if (collection_status.output_num_quantities[outputid] != nquantities) { return LOG_OUTPUTS_CORRUPT; }
		 
    out = &output[(modelid_offset+modelid)*collection_status.num_outputs + outputid];
		 
    if (out->samples == out->allocated) {
      out->allocated *= 2;
      out->data = (double*)safe_realloc(out->data, nquantities * out->allocated * sizeof(double));
      if (!out->data)
	{ return LOG_OUTPUTS_OUT_OF_MEMORY; }
    }
		 
    odata = &out->data[out->samples * nquantities];
		 
    /* Copies each element individually for implicit type conversion from float of 'precision' to double. */
    if(collection_status.precision == 4){
      float *fquantities = (float*) buf->quantities;
      for (quantityid = 0; quantityid < nquantities; ++quantityid) {
	odata[quantityid] = fquantities[quantityid];
      }
      buf = (output_buffer_data *)(fquantities + nquantities);
    }
    else /* collection_status.precision == 8 */{
      double *dquantities = (double*) buf->quantities;
      for (quantityid = 0; quantityid < nquantities; ++quantityid) {
	odata[quantityid] = dquantities[quantityid];
      }
      buf = (output_buffer_data *)(dquantities + nquantities);
    }

    ++out->samples;
  }
  ob->available[modelid] = 0;
	     
  return LOG_OUTPUTS_OK;
}
Example #22
0
/* 
 * -- calibrate
 * 
 * Calibrate the packet timestamps 
 *
 */
void 
calibrate(struct _snifferinfo * info)
{
    struct map_area_header * m = info->m; 
    clock_retimer_t ** cr = info->clock_retimers;	
    uint size = info->retimer_size; 
    uint num;
    uint calibrated; 

    logmsg(V_LOGSNIFFER, "Starting timer calibration\n");

    num = calibrated = 0;
    do {
	struct timeval now;
	uint s, t;

        while (m->k2u_cons >= m->k2u_prod)
            mb();
        t = m->k2u_prod;

        mb();
        gettimeofday(&now, NULL);
        for (s = m->k2u_cons; s < t; s++) {
            uint iface;
            int ind;

            ind = s % RING_SIZE;
            iface = m->k2u_pipe[ind].interface;
            if (iface == (unsigned short)-1)
                continue;

            if (iface >= size) {
                logmsg(V_LOGSNIFFER, 
		    "Extend retimer array: %d -> %d\n", size, iface + 1);
                cr = safe_realloc(cr, (iface + 1) * sizeof(cr[0]));
                memset(cr + size, 0, sizeof(cr[0]) * (iface + 1 - size));
                size = iface + 1;
            }

            if (cr[iface] == NULL) {
                logmsg(V_LOGSNIFFER, "Found interface %d\n", iface);
                cr[iface] = new_clock_retimer("", 0);
                num++;
            }
            calibrated += doTimer(cr[iface], m->k2u_pipe[ind].tstamp, 0, &now);
        }
        discard_packets(m);
    } while (calibrated != num);

    info->retimer_size = size; 
    logmsg(V_LOGSNIFFER, "Calibrated %d interfaces\n", calibrated);
}
Example #23
0
static int update_header_tags(HEADER *h, notmuch_message_t *msg)
{
	struct nm_hdrdata *data = h->data;
	notmuch_tags_t *tags;
	char *tstr = NULL, *p;
	size_t sz = 0;

	dprint(2, (debugfile, "nm: tags update requested (%s)\n", h->env->message_id));

	for (tags = notmuch_message_get_tags(msg);
	     tags && notmuch_tags_valid(tags);
	     notmuch_tags_move_to_next(tags)) {

		const char *t = notmuch_tags_get(tags);
		size_t xsz = t ? strlen(t) : 0;

		if (!xsz)
			continue;

		if (NotmuchHiddenTags) {
			p = strstr(NotmuchHiddenTags, t);

			if (p && (p == NotmuchHiddenTags
				  || *(p - 1) == ','
				  || *(p - 1) == ' ')
			    && (*(p + xsz) == '\0'
				  || *(p + xsz) == ','
				  || *(p + xsz) == ' '))
				continue;
		}

		safe_realloc(&tstr, sz + (sz ? 1 : 0) + xsz + 1);
		p = tstr + sz;
		if (sz) {
			*p++ = ' ';
			sz++;
		}
		memcpy(p, t, xsz + 1);
		sz += xsz;
	}

	if (data->tags && tstr && strcmp(data->tags, tstr) == 0) {
		FREE(&tstr);
		dprint(2, (debugfile, "nm: tags unchanged\n"));
		return 1;
	}

	FREE(&data->tags);
	data->tags = tstr;
	dprint(2, (debugfile, "nm: new tags: '%s'\n", tstr));
	return 0;
}
Example #24
0
/* int mpg123_index(mpg123_handle *mh, off_t **offsets, off_t *step, size_t *fill) */
int attribute_align_arg mpg123_index(mpg123_handle *mh, long **offsets, long *step, size_t *fill)
{
	int err;
	size_t i;
	long smallstep;
	size_t thefill;
	off_t largestep;
	off_t *largeoffsets;
	struct wrap_data *whd;

	whd = wrap_get(mh);
	if(whd == NULL) return MPG123_ERR;

	err = MPG123_LARGENAME(mpg123_index)(mh, &largeoffsets, &largestep, &thefill);
	if(err != MPG123_OK) return err;

	/* For a _very_ large file, even the step could overflow. */
	smallstep = largestep;
	if(smallstep != largestep)
	{
		mh->err = MPG123_LFS_OVERFLOW;
		return MPG123_ERR;
	}
	if(step != NULL) *step = smallstep;

	/* When there are no values stored, there is no table content to take care of.
	   Table pointer does not matter. Mission completed. */
	if(thefill == 0) return MPG123_OK;

	if(fill != NULL) *fill = thefill;

	/* Construct a copy of the index to hand over to the small-minded client. */
	*offsets = safe_realloc(whd->indextable, (*fill)*sizeof(long));
	if(*offsets == NULL)
	{
		mh->err = MPG123_OUT_OF_MEM;
		return MPG123_ERR;
	}
	whd->indextable = *offsets;
	/* Elaborate conversion of each index value, with overflow check. */
	for(i=0; i<*fill; ++i)
	{
		whd->indextable[i] = largeoffsets[i];
		if(whd->indextable[i] != largeoffsets[i])
		{
			mh->err = MPG123_LFS_OVERFLOW;
			return MPG123_ERR;
		}
	}
	/* If we came that far... there should be a valid copy of the table now. */
	return MPG123_OK;
}
Example #25
0
static void rfc2231_join_continuations (PARAMETER **head,
					struct rfc2231_parameter *par)
{
  struct rfc2231_parameter *q;

  char attribute[STRING];
  char charset[STRING];
  char *value = NULL;
  char *valp;
  int encoded;

  size_t l, vl;
  
  while (par)
  {
    value = NULL; l = 0;
    
    strfcpy (attribute, par->attribute, sizeof (attribute));

    if ((encoded = par->encoded))
      valp = rfc2231_get_charset (par->value, charset, sizeof (charset));
    else
      valp = par->value;

    do 
    {
      if (encoded && par->encoded)
	rfc2231_decode_one (par->value, valp);
      
      vl = strlen (par->value);
      
      safe_realloc (&value, l + vl + 1);
      strcpy (value + l, par->value);	/* __STRCPY_CHECKED__ */
      l += vl;

      q = par->next;
      rfc2231_free_parameter (&par);
      if ((par = q))
	valp = par->value;
    } while (par && !strcmp (par->attribute, attribute));
    
    if (value)
    {
      if (encoded)
	mutt_convert_string (&value, charset, Charset, MUTT_ICONV_HOOK_FROM);
      *head = mutt_new_parameter ();
      (*head)->attribute = safe_strdup (attribute);
      (*head)->value = value;
      head = &(*head)->next;
    }
  }
}
Example #26
0
static void
extend_fses (guestfs_h *g)
{
  const size_t n = g->nr_fses + 1;
  struct inspect_fs *p;

  p = safe_realloc (g, g->fses, n * sizeof (struct inspect_fs));

  g->fses = p;
  g->nr_fses = n;

  memset (&g->fses[n-1], 0, sizeof (struct inspect_fs));
}
Example #27
0
/*
 * Increase the capacity by 50%
 */
static void extend_egeq_bank(egeq_bank_t *bank) {
  uint32_t n;

  n = bank->capacity;
  n += n>>1;
  if (n < DEF_EGEQ_BANK_SIZE) {
    n = DEF_EGEQ_BANK_SIZE;
  }
  if (n >= MAX_EGEQ_BANK_SIZE) out_of_memory();

  bank->block = (egeq_elem_t **) safe_realloc(bank->block, n * sizeof(egeq_elem_t *));
  bank->capacity = n;
}
Example #28
0
int cache_setup(unsigned max_cache_img, dword * c_selidx)
{
	cache_selidx = c_selidx;
	ccacher.caches_cap = max_cache_img;

	ccacher.caches =
		safe_realloc(ccacher.caches,
					 ccacher.caches_cap * sizeof(ccacher.caches[0]));

	cacher_cleared = true;

	return 0;
}
Example #29
0
/*
 * Extend: make the term array 50% larger
 */
static void extend_term_store(term_store_t *store) {
  uint32_t n;

  n = store->size + 1;
  n += n>>1;

  if (n >= TERM_STORE_MAX_SIZE) {
    out_of_memory();
  }

  store->size = n;
  store->term = (term_t *) safe_realloc(store->term, n * sizeof(term_t));
}
Example #30
0
File: xaw_c.c Project: 1c0n/xbmc
static void xaw_add_midi_file(char *additional_path) {
    char *files[1],**ret,**tmp;
    int i,nfiles,nfit;
    char *p;

    files[0] = additional_path;
    nfiles = 1;
    ret = expand_file_archives(files, &nfiles);
    if(ret == NULL)
      return;
    tmp = list_of_files;
    titles=(char **)safe_realloc(titles,(number_of_files+nfiles)*sizeof(char *));
    list_of_files=(char **)safe_malloc((number_of_files+nfiles)*sizeof(char *));
    for (i=0;i<number_of_files;i++)
        list_of_files[i]=safe_strdup(tmp[i]);
    for (i=0,nfit=0;i<nfiles;i++) {
        if(check_midi_file(ret[i]) >= 0) {
            p=strrchr(ret[i],'/');
            if (p==NULL) p=ret[i]; else p++;      
            titles[number_of_files+nfit]=(char *)safe_malloc(sizeof(char)*(strlen(p)+ 9));
            list_of_files[number_of_files+nfit]=safe_strdup(ret[i]);
            sprintf(titles[number_of_files+nfit],"%d. %s",number_of_files+nfit+1,p);
            nfit++;
        }
    }
    if(nfit>0) {
        file_table=(int *)safe_realloc(file_table,
                                       (number_of_files+nfit)*sizeof(int));
        for(i = number_of_files; i < number_of_files + nfit; i++)
            file_table[i] = i;
        number_of_files+=nfit;
        sprintf(local_buf, "X %d", nfit);
        a_pipe_write(local_buf);
        for (i=0;i<nfit;i++)
            a_pipe_write(titles[number_of_files-nfit+i]);
    }
    free(ret[0]);
    free(ret);
}