コード例 #1
0
/*-------------------------------------------------------------------------
 * Function:	_lite_PD_rl_syment_d
 *
 * Purpose:	Reclaim the space of the given syment including its
 *		dimensions.
 *
 * Return:	void
 *
 * Programmer:	Adapted from PACT PDB
 *		Mar  5, 1996 12:06 PM EST
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
void
_lite_PD_rl_syment_d (syment *ep) {

    if (ep == NULL) return;

    _lite_PD_rl_dimensions(PD_entry_dimensions(ep));
    _lite_PD_rl_syment(ep);
}
コード例 #2
0
/*-------------------------------------------------------------------------
 * Function:	_lite_PD_rl_descriptor
 *
 * Purpose:	Release a member descriptor
 *
 * Return:	void
 *
 * Programmer:	Adapted from PACT PDB
 *		Mar  5, 1996  4:55 PM EST
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
void
_lite_PD_rl_descriptor (memdes *desc) {

    SFREE(desc->member);
    SFREE(desc->name);
    SFREE(desc->type);
    SFREE(desc->base_type);
    SFREE(desc->cast_memb);

    _lite_PD_rl_dimensions(desc->dimensions);

    SFREE(desc);
}
コード例 #3
0
ファイル: pdb.c プロジェクト: markcmiller86/libmesh_silo
int
lite_PD_write_as_alt (PDBfile *file, char *name, char *intype, char *outtype,
		      lite_SC_byte *vr, int nd, long *ind) {
   int i;
   long start, stop, step, leng;
   char expr[MAXLINE], index[MAXLINE], hname[MAXLINE];
   dimdes *dims, *next, *prev;
   syment *ep;

   prev = NULL;
   dims = NULL;

   strcpy(index, "(");

   for (i = 0; i < nd; i++) {
      start = ind[0];
      stop  = ind[1];
      step  = ind[2];
      ind += 3;

      sprintf(expr, "%ld:%ld:%ld,", start, stop, step);
      strcat(index, expr);

      leng = stop - start + 1L;
      next = _lite_PD_mk_dimensions(start, leng);
      if (dims == NULL) {
	 dims = next;
      } else {
	 prev->next = next;
      }

      prev = next;
   }

   if (strlen(index) > 1) {
      index[strlen(index)-1] = ')';
      sprintf(hname, "%s%s", name, index);
   } else {
      strcpy(hname, name);
   }

   ep  = _PD_write(file, hname, intype, outtype, vr, dims, _append_flag);

   if (ep != NULL) {
      _lite_PD_rl_syment_d(ep);
      return(TRUE);
   } else {
      _lite_PD_rl_dimensions(dims);
      return(FALSE);
   }
}
コード例 #4
0
ファイル: pdb.c プロジェクト: markcmiller86/libmesh_silo
static syment *
_PD_write (PDBfile *file, char *name, char *intype, char *outtype,
	   lite_SC_byte *vr, dimdes *dims, int appnd) {

   int reset;
   syment *ep;
   long number, addr;
   char bf[MAXLINE], fullpath[MAXLINE], *lname;

   _append_flag = FALSE;

   ep = NULL;

   switch (setjmp(_lite_PD_write_err)) {
   case ABORT    : return(NULL);
   case ERR_FREE : return(ep);
   default       : memset(lite_PD_err, 0, MAXLINE);
      break;
   }

   if (file->mode == PD_OPEN) {
      lite_PD_error("FILE OPENED IN READ-ONLY MODE - _PD_WRITE", PD_WRITE);
   }

   strcpy(fullpath, _lite_PD_fixname(file, name));

   /*
    * Append a new block to an existing entry if TRUE.
    */
   if (appnd) {
      strcpy(bf, fullpath);

      /*
       * Do this so that things such as a[20:20].b work properly
       * NOTE: this also implies that a[20:20].b.c works while
       *       a.b[20:20].c doesn't
       * for now this defines the semantics of append (10/6/93)
       */
      lname = lite_SC_firsttok(bf, ".()[]");

      ep = lite_PD_inquire_entry(file, lname, FALSE, NULL);
      if (ep == NULL) {
	 lite_PD_error("CAN'T APPEND TO NON-EXISTING ENTRY - _PD_WRITE",
		       PD_WRITE);
      }
      _lite_PD_adj_dimensions(file, fullpath, ep);

      /*
       * Extend the syment.
       */
      _lite_PD_add_block(file, ep, dims);
   }

   addr = file->chrtaddr;
   ep   = _lite_PD_effective_ep(file, fullpath, FALSE, NULL);

   if (ep != NULL) {
      /*
       * If the variable already exists use the existing file info.
       */
      addr   = PD_entry_address(ep);
      _lite_PD_rl_dimensions(dims);
      lname  = fullpath;
      reset  = FALSE;
   } else {
      /*
       * If the variable doesn't exist define it to the file.
       */
      number = _lite_PD_comp_num(dims);
      ep     = _lite_PD_mk_syment(outtype, number, addr, NULL, dims);

      strcpy(bf, fullpath);
      lname = lite_SC_firsttok(bf, ".([ ");
      _lite_PD_e_install(lname, ep, file->symtab);

      reset = TRUE;
   }

   if (file->virtual_internal) {
      SC_address ad;

      ad.memaddr = vr;
      ep->blocks->diskaddr = ad.diskaddr;
      lite_SC_mark(vr, 1);
      ep = lite_PD_copy_syment(ep);
   } else {
      if (outtype == NULL) outtype = PD_entry_type(ep);

      if (intype == NULL) intype = outtype;

      /*
       * Go to the correct address.
       */
      if (io_seek(file->stream, addr, SEEK_SET)) {
	 lite_PD_error("FSEEK FAILED TO FIND CURRENT ADDRESS - _PD_WRITE",
		       PD_WRITE);
      }

      /*
       * Do the low level write.
       */
      if (!_lite_PD_hyper_write(file, lname, ep, vr, intype)) {
	 lite_PD_error("CAN'T WRITE VARIABLE - _PD_WRITE", PD_WRITE);
      }

      /*
       * If the variable didn't previously exist we're at the end
       * of the file.
       */
      if (reset) {
	 file->chrtaddr = io_tell(file->stream);
	 if (file->chrtaddr == -1L) {
	    lite_PD_error("CAN'T FIND ADDRESS OF NEXT VARIABLE - _PD_WRITE",
			  PD_WRITE);
	 }

	 /*
	  * Make a releasable copy of the entry
	  * SX depends on this critically!!
	  */
	 ep = lite_PD_copy_syment(ep);
      }
   }

   return(ep);
}