Пример #1
0
/* UpdateScrollbar --
 *	Call the -scrollcommand callback to sync the scrollbar.
 * 	Returns: Whatever the -scrollcommand does.
 */
static int UpdateScrollbar(Tcl_Interp *interp, ScrollHandle h)
{
    Scrollable *s = h->scrollPtr;
    WidgetCore *corePtr = h->corePtr;
    char arg1[TCL_DOUBLE_SPACE + 2];
    char arg2[TCL_DOUBLE_SPACE + 2];
    int code;

    h->flags &= ~SCROLL_UPDATE_REQUIRED;

    if (s->scrollCmd == NULL) {
	return TCL_OK;
    }

    arg1[0] = arg2[0] = ' ';
    Tcl_PrintDouble(interp, (double)s->first / s->total, arg1+1);
    Tcl_PrintDouble(interp, (double)s->last / s->total, arg2+1);

    Tcl_Preserve(corePtr);
    code = Tcl_VarEval(interp, s->scrollCmd, arg1, arg2, NULL);
    if (WidgetDestroyed(corePtr)) {
	Tcl_Release(corePtr);
	return TCL_ERROR;
    }
    Tcl_Release(corePtr);

    if (code != TCL_OK && !Tcl_InterpDeleted(interp)) {
	/* Disable the -scrollcommand, add to stack trace:
	 */
	ckfree(s->scrollCmd);
	s->scrollCmd = 0;

	Tcl_AddErrorInfo(interp, /* @@@ "horizontal" / "vertical" */
		"\n    (scrolling command executed by ");
	Tcl_AddErrorInfo(interp, Tk_PathName(h->corePtr->tkwin));
	Tcl_AddErrorInfo(interp, ")");
    }
    return code;
}
Пример #2
0
extern char *
#endif
TclKit_SetKitPath(const char *kitPath)
{
    /*
     * Allow someone to define an alternate path to the base kit
     * than 'info nameofexecutable'.
     * NOTE: this must be provided as a utf-8 encoded string or it may
     *       fail when the path includes non-ascii characters.
     */
    if (kitPath) {
      	int len = (int)strlen(kitPath);
      	if (tclKitPath) {
      	    ckfree(tclKitPath);
      	}

      	tclKitPath = (char *) ckalloc(len + 1);
      	memcpy(tclKitPath, kitPath, len);
      	tclKitPath[len] = '\0';
    }
    return tclKitPath;
}
Пример #3
0
void
popredir(void)
{
	struct redirtab *rp = redirlist;
	int i;

	for (i = 0 ; i < 10 ; i++) {
		if (rp->renamed[i] != EMPTY) {
			if (rp->renamed[i] >= 0) {
				dup2(rp->renamed[i], i);
				close(rp->renamed[i]);
			} else {
				close(i);
			}
		}
	}
	INTOFF;
	fd0_redirected = rp->fd0_redirected;
	redirlist = rp->next;
	ckfree(rp);
	INTON;
}
Пример #4
0
void
TclHandleRelease(
    TclHandle handle)		/* Unregister interest in the block of memory
				 * referenced by this handle. */
{
    HandleStruct *handlePtr;

    handlePtr = (HandleStruct *) handle;
#ifdef TCL_MEM_DEBUG
    if (handlePtr->refCount == 0x61616161) {
	Tcl_Panic("using previously disposed TclHandle %x", handlePtr);
    }
    if ((handlePtr->ptr != NULL) && (handlePtr->ptr != handlePtr->ptr2)) {
	Tcl_Panic("someone has changed the block referenced by the handle %x\nfrom %x to %x",
		handlePtr, handlePtr->ptr2, handlePtr->ptr);
    }
#endif
    handlePtr->refCount--;
    if ((handlePtr->refCount == 0) && (handlePtr->ptr == NULL)) {
	ckfree((char *) handlePtr);
    }
}
Пример #5
0
void
reset(shinstance *psh) {

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/eval.c: */
      {
	      psh->evalskip = 0;
	      psh->loopnest = 0;
	      psh->funcnest = 0;
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */
      {
	      if (psh->exception != EXSHELLPROC)
		      psh->parselleft = psh->parsenleft = 0;	/* clear input buffer */
	      popallfiles(psh);
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/output.c: */
      {
	      psh->out1 = &psh->output;
	      psh->out2 = &psh->errout;
	      if (psh->memout.buf != NULL) {
		      ckfree(psh, psh->memout.buf);
		      psh->memout.buf = NULL;
	      }
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/parser.c: */
      {
	      psh->tokpushback = 0;
	      psh->checkkwd = 0;
      }

      /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/redir.c: */
      {
	      while (psh->redirlist)
		      popredir(psh);
      }
}
Пример #6
0
void
TnmVectorAdd(TnmVector *vPtr, ClientData clientData)
{
    int i;
    size_t size;
    ClientData *dynamicSpace;

    if (vPtr->size == vPtr->spaceAvl) {
	vPtr->spaceAvl += TNM_VECTOR_STATIC_SIZE;
	size = (vPtr->spaceAvl + 1) * sizeof(ClientData);
	dynamicSpace = (ClientData *) ckalloc(size);
	memset((char *) dynamicSpace, 0, size);
	for (i = 0; i < vPtr->size; i++) {
	    dynamicSpace[i] = vPtr->elements[i];
	}
	if (vPtr->elements != vPtr->staticSpace) {
	    ckfree((char *) vPtr->elements);
	}
	vPtr->elements = dynamicSpace;
    }
    vPtr->elements[vPtr->size++] = clientData;
}
Пример #7
0
Genomic * get_Genomic_from_Gene(Gene * gene)
{
  Genomic * gn;
  char buffer[64];

  /*  fprintf(stdout,"Getting genomic...\n"); */
  if( gene->genomic != NULL )
    return gene->genomic;

  if( gene->parent == NULL ) {
    warn("Cannot get Gene, as no parent genomic region!");
    return NULL;
  }


  gn = get_Genomic_from_GenomicRegion(gene->parent);

  if( gn == NULL) {
    warn("Cannot get Gene, as no sequence in genomic region!");
    return NULL;
  }

  if( gn->baseseq->offset < gn->baseseq->end) {
    if( gene->start > gene->end ) 
      gene->genomic = truncate_Genomic(gn,gene->start-gn->baseseq->offset+2,gene->end-gn->baseseq->offset+2);
    else 
      gene->genomic = truncate_Genomic(gn,gene->start-gn->baseseq->offset+1,gene->end-gn->baseseq->offset+1);
  }
  else {
    gene->genomic = truncate_Genomic(gn,gn->baseseq->offset-1 - gene->start,gn->baseseq->offset-1 - gene->end);
  }

  sprintf(buffer,"%s.[%d:%d]",Genomic_name(gn),gene->start+1,gene->end);
  ckfree(gene->genomic->baseseq->name);
  gene->genomic->baseseq->name = stringalloc(buffer);


  return gene->genomic;
}
void
Tcl_EventuallyFree(
    ClientData clientData,	/* Pointer to malloc'ed block of memory. */
    Tcl_FreeProc *freeProc)	/* Function to actually do free. */
{
    Reference *refPtr;
    int i;

    /*
     * See if there is a reference for this pointer. If so, set its "mustFree"
     * flag (the flag had better not be set already!).
     */

    Tcl_MutexLock(&preserveMutex);
    for (i = 0, refPtr = refArray; i < inUse; i++, refPtr++) {
	if (refPtr->clientData != clientData) {
	    continue;
	}
	if (refPtr->mustFree) {
	    Tcl_Panic("Tcl_EventuallyFree called twice for 0x%x",
		    clientData);
        }
        refPtr->mustFree = 1;
	refPtr->freeProc = freeProc;
	Tcl_MutexUnlock(&preserveMutex);
        return;
    }
    Tcl_MutexUnlock(&preserveMutex);

    /*
     * No reference for this block.  Free it now.
     */

    if (freeProc == TCL_DYNAMIC) {
	ckfree((char *) clientData);
    } else {
	(*freeProc)((char *)clientData);
    }
}
Пример #9
0
void
popredir(void)
{
	struct redirtab *rp = redirlist;
	int i;

	for (i = 0 ; i < 10 ; i++) {
		if (rp->renamed[i] != EMPTY) {
                        if (i == 0)
                                fd0_redirected--;
			close(i);
			if (rp->renamed[i] >= 0) {
				copyfd(rp->renamed[i], i, 1);
				close(rp->renamed[i]);
			}
		}
	}
	INTOFF;
	redirlist = rp->next;
	ckfree(rp);
	INTON;
}
Пример #10
0
static void
printaliases(void)
{
	int i, j;
	struct alias **sorted, *ap;

	INTOFF;
	sorted = ckmalloc(aliases * sizeof(*sorted));
	j = 0;
	for (i = 0; i < ATABSIZE; i++)
		for (ap = atab[i]; ap; ap = ap->next)
			if (*ap->name != '\0')
				sorted[j++] = ap;
	qsort(sorted, aliases, sizeof(*sorted), comparealiases);
	for (i = 0; i < aliases; i++) {
		printalias(sorted[i]);
		if (int_pending())
			break;
	}
	ckfree(sorted);
	INTON;
}
Пример #11
0
BaseMatrix * free_BaseMatrix(BaseMatrix * obj)
{
  int i;

  if( obj == NULL ) {
    warn("Trying to free NULL basematrix object. Should be trappable");
    return NULL;
  }

  if( obj->dynamite_hard_link > 1 ) {
    obj->dynamite_hard_link--;
    return NULL;
  }
 
  if(obj->matrix != NULL ) {
    for(i=0;i<obj->leni;i++)
      if( obj->matrix[i] != NULL ) {
	ckfree(obj->matrix[i]);
      }
    free(obj->matrix);
  }
  

  if( obj->spec_len > 0 ) {
    if( obj->specmatrix == NULL ) {
      warn("Bad karma. you have a special matrix of length %d, but a NULL specmatrix pointer. I'm not going to free it!",obj->spec_len);
    } else {
      for(i=0;i<obj->spec_len;i++) {
	if( obj->specmatrix[i] != NULL ) {
	  ckfree(obj->specmatrix[i]);
	}
      }
      ckfree(obj->specmatrix);
    } /* end of else */
  } /* end of if specials */

  if( obj->offsetmem != NULL )
    ckfree(obj->offsetmem);
  if( obj->setmem != NULL )
    ckfree(obj->setmem);


  ckfree(obj);

  return NULL;
}
Пример #12
0
static int
ForeachLoopStep (ClientData data[], Tcl_Interp * interp, int result)
{
  ForeachState *const statePtr = data[0];
  Tcl_Obj *const varPtr = data[1];
  DBFHandle const dbfHandle = data[2];
  Tcl_Obj *const bodyPtr = data[3];

  switch (result)
    {
    case TCL_CONTINUE:
      result = TCL_OK;
    case TCL_OK:
      break;
    case TCL_BREAK:
      result = TCL_OK;
      goto done;
    case TCL_ERROR:
    default:
      goto done;
    }

  if (statePtr->length > ++statePtr->i)
    {
      if ((result =
           ForeachAssignments (interp, statePtr, varPtr, dbfHandle)) != TCL_OK)
        {
          goto done;
        }
      Tcl_NRAddCallback (interp, ForeachLoopStep, statePtr, varPtr, dbfHandle,
                         bodyPtr);
      return Tcl_NREvalObj (interp, bodyPtr, 0);
    }
  Tcl_ResetResult (interp);
done:
  ckfree ((char *) statePtr);
  return result;
}
Пример #13
0
static void
reprocess(int startloc, int flag, int subtype, int quoted,
    struct worddest *dst)
{
	static char *buf = NULL;
	static size_t buflen = 0;
	char *startp;
	size_t len, zpos, zlen;

	startp = stackblock() + startloc;
	len = expdest - startp;
	if (len >= SIZE_MAX / 2)
		abort();
	INTOFF;
	if (len >= buflen) {
		ckfree(buf);
		buf = NULL;
	}
	if (buflen < 128)
		buflen = 128;
	while (len >= buflen)
		buflen <<= 1;
	if (buf == NULL)
		buf = ckmalloc(buflen);
	INTON;
	memcpy(buf, startp, len);
	buf[len] = '\0';
	STADJUST(-len, expdest);
	for (zpos = 0;;) {
		zlen = strlen(buf + zpos);
		strtodest(buf + zpos, flag, subtype, quoted, dst);
		zpos += zlen + 1;
		if (zpos == len + 1)
			break;
		if (flag & EXP_SPLIT && (quoted || (zlen > 0 && zpos < len)))
			NEXTWORD('\0', flag, expdest, dst);
	}
}
Пример #14
0
static void
IvyMsgCB(IvyClientPtr	app,
	 void		*user_data,
	 int		argc,
	 char		**argv)
{
  filter_struct	*filter = (filter_struct *) user_data;
  int		result, i, size;
  char		*script_to_call;
  
  size = strlen(filter->script) + 3;
  for (i = 0; i < argc; i++) {
    size += strlen(argv[i]) + 3;
  }
  size ++;
  size += strlen(IvyGetApplicationName(app))+4;
  script_to_call = ckalloc(size);
  strcpy(script_to_call, filter->script);
  strcat(script_to_call, " \"");
  strcat(script_to_call, IvyGetApplicationName(app));
  strcat(script_to_call, "\"");
  /* strcat(script_to_call, " {"); */
  for (i = 0; i < argc; i++) {
    strcat(script_to_call, " \"");
	strcat(script_to_call, argv[i]);
    strcat(script_to_call, "\"");
  }
  /* strcat(script_to_call, " }"); */
  
  Tcl_Preserve(filter->interp);
  result = Tcl_GlobalEval(filter->interp, script_to_call);
  ckfree(script_to_call);
  
  if (result != TCL_OK) {
    Tcl_BackgroundError(filter->interp);
  }
  Tcl_Release(filter->interp);
}
Пример #15
0
/* Function:  free_cDNADB(obj)
 *
 * Descrip:    Free Function: removes the memory held by obj
 *             Will chain up to owned members and clear all lists
 *
 *
 * Arg:        obj [UNKN ] Object that is free'd [cDNADB *]
 *
 * Return [UNKN ]  Undocumented return value [cDNADB *]
 *
 */
cDNADB * free_cDNADB(cDNADB * obj) 
{
    int return_early = 0;    


    if( obj == NULL) {  
      warn("Attempting to free a NULL pointer to a cDNADB obj. Should be trappable");    
      return NULL;   
      }  


#ifdef PTHREAD   
    assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); 
#endif   
    if( obj->dynamite_hard_link > 1)     {  
      return_early = 1;  
      obj->dynamite_hard_link--; 
      }  
#ifdef PTHREAD   
    assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);   
#endif   
    if( return_early == 1)   
      return NULL;   
    if( obj->forw != NULL)   
      free_ComplexSequence(obj->forw);   
    if( obj->rev != NULL)    
      free_ComplexSequence(obj->rev);    
    if( obj->sdb != NULL)    
      free_SequenceDB(obj->sdb);     
    if( obj->current != NULL)    
      free_Sequence(obj->current);   
    if( obj->cses != NULL)   
      free_ComplexSequenceEvalSet(obj->cses);    


    ckfree(obj); 
    return NULL; 
}    
Пример #16
0
/* Function:  free_GeneStats(obj)
 *
 * Descrip:    Free Function: removes the memory held by obj
 *             Will chain up to owned members and clear all lists
 *
 *
 * Arg:        obj [UNKN ] Object that is free'd [GeneStats *]
 *
 * Return [UNKN ]  Undocumented return value [GeneStats *]
 *
 */
GeneStats * free_GeneStats(GeneStats * obj) 
{
    int return_early = 0;    


    if( obj == NULL) {  
      warn("Attempting to free a NULL pointer to a GeneStats obj. Should be trappable"); 
      return NULL;   
      }  


#ifdef PTHREAD   
    assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); 
#endif   
    if( obj->dynamite_hard_link > 1)     {  
      return_early = 1;  
      obj->dynamite_hard_link--; 
      }  
#ifdef PTHREAD   
    assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);   
#endif   
    if( return_early == 1)   
      return NULL;   
    if( obj->splice5 != NULL)    
      free_SeqAlign(obj->splice5);   
    if( obj->splice3 != NULL)    
      free_SeqAlign(obj->splice3);   
    if( obj->intron != NULL) 
      free_RandomModelDNA(obj->intron);  
    if( obj->polyp != NULL)  
      free_RandomModelDNA(obj->polyp);   
    if( obj->rnd != NULL)    
      free_RandomModelDNA(obj->rnd);     


    ckfree(obj); 
    return NULL; 
}    
Пример #17
0
void
reset() {

      /* from eval.c: */
      {
	      evalskip = 0;
	      loopnest = 0;
	      funcnest = 0;
      }

      /* from input.c: */
      {
	      if (exception != EXSHELLPROC)
		      parsenleft = 0;            /* clear input buffer */
	      popallfiles();
      }

      /* from parser.c: */
      {
	      tokpushback = 0;
      }

      /* from redir.c: */
      {
	      while (redirlist)
		      popredir();
      }

      /* from output.c: */
      {
	      out1 = &output;
	      out2 = &errout;
	      if (memout.buf != NULL) {
		      ckfree(memout.buf);
		      memout.buf = NULL;
	      }
      }
}
Пример #18
0
/*++

InterpDeleteHandler

    Frees the state structure for an interpreter that is being deleted.

Arguments:
    clientData - Pointer to a "ExtState" structure.

    interp     - Current interpreter.

Return Value:
    None.

--*/
static void
InterpDeleteHandler(
    ClientData clientData,
    Tcl_Interp *interp
    )
{
    ExtState *statePtr = (ExtState *)clientData;
    StateList *stateListPtr;

    if (statePtr == NULL) {
        return;
    }

    Tcl_MutexLock(&stateMutex);
    for (stateListPtr = stateListHead; stateListPtr != NULL; stateListPtr = stateListPtr->next) {

        if (statePtr == stateListPtr->state) {
            // Remove the interpreter's state from the list.
            if (stateListPtr->prev == NULL) {
                stateListHead = stateListPtr->next;
                if (stateListPtr->next != NULL) {
                    stateListHead->prev = NULL;
                }
            } else if (stateListPtr->next == NULL) {
                stateListPtr->prev->next = NULL;
            } else {
                stateListPtr->prev->next = stateListPtr->next;
                stateListPtr->next->prev = stateListPtr->prev;
            }

            ckfree((char *)stateListPtr);
            break;
        }
    }
    Tcl_MutexUnlock(&stateMutex);

    FreeState(statePtr);
}
Пример #19
0
static void act_makeemptyfield (pos_node ps1, pos_node ps2)
	{ value v1 = calc_affix_value (ps1, lower_side);
	  value v2 = calc_affix_value (ps2, lower_side);
	  /* Insert code here */
	  if ((v1 -> tag == integer_value) && (v2 -> tag == integer_value))
	     { char *save_field = field;			/* Ugh */
	       int save_width = width;
	       int save_height = height;
	       int ix;
	       width = v1 -> u.inum;
	       height = v2 -> u.inum;
	       field = (char *) ckcalloc (width*height, sizeof (char));
	       for (ix = 0; ix < width * height; ix++) field[ix] = 0;
	       callq ();
	       ckfree (field);
	       height = save_height;
	       width = save_width;
	       field = save_field;
	     };
	  /* End of insertion */
	  rfre_value (v1);
	  rfre_value (v2);
	};
Пример #20
0
int
dlclose(
    void *handle
) {
    LibraryList *ptr, *prevPtr;

    ptr = libraryList; prevPtr = NULL;
    while (ptr != NULL) {
	if (ptr->handle == (HINSTANCE) handle) {
	    FreeLibrary((HINSTANCE) handle);
	    if (prevPtr) {
		prevPtr->nextPtr = ptr->nextPtr;
	    } else {
		libraryList = ptr->nextPtr;
	    }
	    ckfree((char *) ptr);
	    return 0;
	}
	prevPtr = ptr;
	ptr = ptr->nextPtr;
    }
    return -1;
}
Пример #21
0
void
GaussianBlur2D(
    GaussianFilterSet filterPtr, 
				/* Filter to apply */
    int height,			/* Height of the images */
    int width,			/* Width of the images */
    float* inputImage,		/* Input image: (height x width) array of
				 * float's, row-major order */
    float* outputImage		/* Output image: (height x width) array of
				 * float's, row-major order */
) {
    int area = height * width;
    float* tempImage = (float*) ckalloc(area * sizeof(float));

    /* 
     * Filter first the rows and then the columns.
     */

    GaussianFilter01(filterPtr, 0, height, width, inputImage, tempImage);
    GaussianFilter10(filterPtr, 0, height, width, tempImage, outputImage);

    ckfree((char*)tempImage);
}
Пример #22
0
/* Function:  free_SpliceSiteModel(obj)
 *
 * Descrip:    Free Function: removes the memory held by obj
 *             Will chain up to owned members and clear all lists
 *
 *
 * Arg:        obj [UNKN ] Object that is free'd [SpliceSiteModel *]
 *
 * Return [UNKN ]  Undocumented return value [SpliceSiteModel *]
 *
 */
SpliceSiteModel * free_SpliceSiteModel(SpliceSiteModel * obj) 
{


    if( obj == NULL) {  
      warn("Attempting to free a NULL pointer to a SpliceSiteModel obj. Should be trappable");   
      return NULL;   
      }  


    if( obj->dynamite_hard_link > 1)     {  
      obj->dynamite_hard_link--; 
      return NULL;   
      }  
    if( obj->cc != NULL) 
      free_ComplexConsensi(obj->cc);     
    if( obj->rmds != NULL)   
      free_RandomModelDNAScore(obj->rmds);   


    ckfree(obj); 
    return NULL; 
}    
Пример #23
0
static int
FileCloseProc(
    ClientData instanceData,	/* File state. */
    Tcl_Interp *interp)		/* For error reporting - unused. */
{
    FileState *fsPtr = instanceData;
    int errorCode = 0;

    Tcl_DeleteFileHandler(fsPtr->fd);

    /*
     * Do not close standard channels while in thread-exit.
     */

    if (!TclInThreadExit()
	    || ((fsPtr->fd != 0) && (fsPtr->fd != 1) && (fsPtr->fd != 2))) {
	if (close(fsPtr->fd) < 0) {
	    errorCode = errno;
	}
    }
    ckfree(fsPtr);
    return errorCode;
}
Пример #24
0
int
shiftcmd(int argc, char **argv)
{
	int n;
	char **ap1, **ap2;

	n = 1;
	if (argc > 1)
		n = number(argv[1]);
	if (n > shellparam.nparam)
		return 1;
	INTOFF;
	shellparam.nparam -= n;
	for (ap1 = shellparam.p ; --n >= 0 ; ap1++) {
		if (shellparam.malloc)
			ckfree(*ap1);
	}
	ap2 = shellparam.p;
	while ((*ap2++ = *ap1++) != NULL);
	shellparam.reset = 1;
	INTON;
	return 0;
}
Пример #25
0
int
shiftcmd(int argc, char **argv)
{
	int n;
	char **ap1, **ap2;

	n = 1;
	if (argc > 1)
		n = number(argv[1]);
	if (n > shellparam.nparam)
		error("can't shift that many");
	INTOFF;
	shellparam.nparam -= n;
	for (ap1 = shellparam.p ; --n >= 0 ; ap1++) {
		if (shellparam.malloc)
			ckfree(*ap1);
	}
	ap2 = shellparam.p;
	while ((*ap2++ = *ap1++) != NULL);
	shellparam.optnext = NULL;
	INTON;
	return 0;
}
Пример #26
0
void DBus_CallResult(DBusPendingCall *pending, void *data)
{
   DBusMessage *msg;
   Tcl_CallData *dataPtr = data;
   Tcl_DBusEvent *evPtr;
   
   msg = dbus_pending_call_steal_reply(pending);
   /* free the pending message handle */
   dbus_pending_call_unref(pending);
   /* Allocate a DBus event structure and copy in some basic data */
   evPtr = (Tcl_DBusEvent *) ckalloc(sizeof(Tcl_DBusEvent));
   evPtr->interp = dataPtr->interp;
   evPtr->script = dataPtr->script;
   evPtr->conn = dataPtr->conn;
   /* Fill in the rest of the DBus event structure */
   evPtr->event.proc = DBus_EventHandler;
   evPtr->msg = msg;
   /* Don't send a reply on the reply */
   evPtr->flags = dataPtr->flags | DBUSFLAG_NOREPLY;
   Tcl_QueueEvent((Tcl_Event *) evPtr, TCL_QUEUE_TAIL);
   /* Free the DBus handler data structure */
   ckfree(data);
}
Пример #27
0
static void
LostSelection(
    ClientData clientData)	/* Pointer to LostCommand structure. */
{
    LostCommand *lostPtr = clientData;
    Tcl_Obj *objPtr;
    Tcl_Interp *interp;
    int code;

    interp = lostPtr->interp;
    Tcl_Preserve(interp);

    /*
     * Execute the command. Save the interpreter's result, if any, and restore
     * it after executing the command.
     */

    objPtr = Tcl_GetObjResult(interp);
    Tcl_IncrRefCount(objPtr);
    Tcl_ResetResult(interp);

    code = TkCopyAndGlobalEval(interp, lostPtr->command);
    if (code != TCL_OK) {
	Tcl_BackgroundException(interp, code);
    }

    Tcl_SetObjResult(interp, objPtr);
    Tcl_DecrRefCount(objPtr);

    Tcl_Release(interp);

    /*
     * Free the storage for the command, since we're done with it now.
     */

    ckfree((char *) lostPtr);
}
Пример #28
0
void
TkTextWinFreeClient(
    Tcl_HashEntry *hPtr,	/* Hash entry corresponding to this client, or
				 * NULL */
    TkTextEmbWindowClient *client)
				/* Client data structure, with the 'tkwin'
				 * field to be cleaned up. */
{
    if (hPtr != NULL) {
	/*
	 * (It's possible for there to be no hash table entry for this window,
	 * if an error occurred while creating the window segment but before
	 * the window got added to the table)
	 */

	Tcl_DeleteHashEntry(hPtr);
    }

    /*
     * Delete the event handler for the window before destroying the window,
     * so that EmbWinStructureProc doesn't get called (we'll already do
     * everything that it would have done, and it will just get confused).
     */

    if (client->tkwin != NULL) {
	Tk_DeleteEventHandler(client->tkwin, StructureNotifyMask,
		EmbWinStructureProc, client);
	Tk_DestroyWindow(client->tkwin);
    }
    Tcl_CancelIdleCall(EmbWinDelayedUnmap, client);

    /*
     * Free up this client.
     */

    ckfree((char *) client);
}
Пример #29
0
static void
FinishedWithFont(
    UnixFtFont *fontPtr)
{
    Display *display = fontPtr->display;
    int i;
    Tk_ErrorHandler handler =
	    Tk_CreateErrorHandler(display, -1, -1, -1, NULL, NULL);

    for (i = 0; i < fontPtr->nfaces; i++) {
	if (fontPtr->faces[i].ftFont) {
	    XftFontClose(fontPtr->display, fontPtr->faces[i].ftFont);
	}
	if (fontPtr->faces[i].ft0Font) {
	    XftFontClose(fontPtr->display, fontPtr->faces[i].ft0Font);
	}
	if (fontPtr->faces[i].charset) {
	    FcCharSetDestroy(fontPtr->faces[i].charset);
	}
    }
    if (fontPtr->faces) {
	ckfree(fontPtr->faces);
    }
    if (fontPtr->pattern) {
	FcPatternDestroy(fontPtr->pattern);
    }
    if (fontPtr->ftDraw) {
	XftDrawDestroy(fontPtr->ftDraw);
    }
    if (fontPtr->font.fid) {
	XUnloadFont(fontPtr->display, fontPtr->font.fid);
    }
    if (fontPtr->fontset) {
	FcFontSetDestroy(fontPtr->fontset);
    }
    Tk_DeleteErrorHandler(handler);
}
Пример #30
0
    /* Function:  free_DnaProfileNode(obj)
     *
     * Descrip:    Free Function: removes the memory held by obj
     *             Will chain up to owned members and clear all lists
     *
     *
     * Arg:        obj [UNKN ] Object that is free'd [DnaProfileNode *]
     *
     * Return [UNKN ]  Undocumented return value [DnaProfileNode *]
     *
     */
    DnaProfileNode * free_DnaProfileNode(DnaProfileNode * obj)
    {
        int return_early = 0;


        if( obj == NULL) {
            warn("Attempting to free a NULL pointer to a DnaProfileNode obj. Should be trappable");
            return NULL;
        }


#ifdef PTHREAD
        assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0);
#endif
        if( obj->dynamite_hard_link > 1)     {
            return_early = 1;
            obj->dynamite_hard_link--;
        }
#ifdef PTHREAD
        assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);
#endif
        if( return_early == 1)
            return NULL;
        if( obj->leaf != NULL)
            free_Sequence(obj->leaf);
        if( obj->set != NULL)
            free_DnaProfileSet(obj->set);
        if( obj->left != NULL)
            free_DnaProfileNode(obj->left);
        if( obj->right != NULL)
            free_DnaProfileNode(obj->right);
        /* obj->parent is linked in */


        ckfree(obj);
        return NULL;
    }