コード例 #1
0
ファイル: liqRibData.cpp プロジェクト: virtualritz/liquidmaya
liqRibData::~liqRibData()
{
  // clean up and additional data
  LIQDEBUGPRINTF("-> freeing additional ribdata: " );
  LIQDEBUGPRINTF(objDagPath.fullPathName().asChar());
  LIQDEBUGPRINTF("\n" );
  // Class destructor should be called
#if 0
  std::vector<rTokenPointer>::iterator iter = tokenPointerArray.begin();
  while ( iter != tokenPointerArray.end() ) {
    LIQDEBUGPRINTF( "-> freeing addition ribdata: %s\n", iter->tokenName );
    if ( iter->tokenFloats != NULL ) {
      lfree( iter->tokenFloats );
      iter->tokenFloats = NULL;
    }
    if ( iter->tokenString != NULL ) {
      lfree( iter->tokenString );
      iter->tokenString = NULL;
    }
    ++iter;
  }
#endif
  tokenPointerArray.clear();
  LIQDEBUGPRINTF("-> finished freeing additional ribdata: " );
  LIQDEBUGPRINTF(objDagPath.fullPathName().asChar());
  LIQDEBUGPRINTF("\n" );
}
コード例 #2
0
ファイル: thread_pool.c プロジェクト: andreiw/polaris
static void
delete_pool(tpool_t *tpool)
{
	tpool_job_t *job;

	ASSERT(tpool->tp_current == 0 && tpool->tp_active == NULL);

	/*
	 * Unlink the pool from the global list of all pools.
	 */
	lmutex_lock(&thread_pool_lock);
	if (thread_pools == tpool)
		thread_pools = tpool->tp_forw;
	if (thread_pools == tpool)
		thread_pools = NULL;
	else {
		tpool->tp_back->tp_forw = tpool->tp_forw;
		tpool->tp_forw->tp_back = tpool->tp_back;
	}
	lmutex_unlock(&thread_pool_lock);

	/*
	 * There should be no pending jobs, but just in case...
	 */
	for (job = tpool->tp_head; job != NULL; job = tpool->tp_head) {
		tpool->tp_head = job->tpj_next;
		lfree(job, sizeof (*job));
	}
	(void) pthread_attr_destroy(&tpool->tp_attr);
	lfree(tpool, sizeof (*tpool));
}
コード例 #3
0
ファイル: folding.c プロジェクト: axelmuhr/Helios-NG
PASCAL NEAR removefold(
  int f,
  int n )
{
	BUFFER *bp;		 /* buffer having fold removed */
	WINDOW *wp;		 /* windows to fix up pointers in as well */
	LINE   *lp;		 /* line loop for reset of margin */
	int    margval;		 /* value to set margin to */

        if (curbp->b_mode&MDVIEW)       /* don't allow this command if  */
                return(rdonly());       /* we are in read only mode     */

	/* find the proper buffer */
	bp = curwp->w_bufp;		

	if (curwp->w_dotp->l_type == LSOFOLD) {

		/* set line types to normal */
		curwp->w_dotp->l_type = LNORMAL;
		curwp->w_dotp->l_foldp->l_type = LNORMAL;

		/* set all margins to that of any outer fold */
		margval = minleftmarg(curwp->w_dotp);
		lp = curwp->w_dotp->l_fp;
		while (lp != curwp->w_dotp->l_foldp) {
			lp->l_lmargin = margval;
			lp = lforw(lp);
		}

		/* and remove them */
		lfree(curwp->w_dotp->l_foldp);
		lfree(curwp->w_dotp);

		/* let all the proper windows be updated */
		wp = wheadp;
		while (wp) {
			if (wp->w_bufp == bp)
				wp->w_flag |= (WFHARD|WFMODE);
			wp = wp->w_wndp;
		}
		bp->b_flag |= BFCHG; /* flag change */
		mlwrite(TEXT233);
		/* "[Fold Removed]" */
		return(TRUE);
	}
	else {
		mlwrite(TEXT235);
		/* "%% Not a fold line" */
		return(FALSE);
	}
}
コード例 #4
0
ファイル: syslinux.c プロジェクト: numascale/firmware
void OS::udp_open(void)
{
	t_PXENV_TFTP_CLOSE *tftp_close_param = (t_PXENV_TFTP_CLOSE *)lzalloc(sizeof(t_PXENV_TFTP_CLOSE));
	xassert(tftp_close_param);
	pxeapi_call(PXENV_TFTP_CLOSE, (uint8_t *)tftp_close_param);
//	printf("TFTP close returns: %d\n", tftp_close_param->Status);
	lfree(tftp_close_param);

	t_PXENV_UDP_OPEN *pxe_open_param = (t_PXENV_UDP_OPEN *)lzalloc(sizeof(t_PXENV_UDP_OPEN));
	xassert(pxe_open_param);
	pxe_open_param->src_ip = os->ip.s_addr;
	pxeapi_call(PXENV_UDP_OPEN, (uint8_t *)pxe_open_param);
//	printf("PXE UDP open returns: %d\n", pxe_open_param->status);
	lfree(pxe_open_param);
}
コード例 #5
0
ファイル: FAT.C プロジェクト: FDOS/defrag
unsigned short LARGE *readfat(int disk, unsigned short nclusters, long sector,
                              int secsfat)
{
int i;
SIZE_T bufsiz;
unsigned short LARGE *buf;

    bufsiz = ((SIZE_T)nclusters+2) * sizeof(short);

    if (bufsiz & 1)
        ++bufsiz;

    if ((buf = lmalloc(bufsiz)) == NULL)
        return NULL;

#ifndef NEED_LARGE
    memset(buf,0,bufsiz);
#endif

    if (nclusters < 4096)
        i = readfat12(disk,nclusters,sector,secsfat,buf);
    else
        i = readfat16(disk,nclusters,sector,secsfat,buf);

    if (i != 1) {
        lfree(buf);
        return NULL;
    }

    return buf;
}
コード例 #6
0
ファイル: pxe_get_nic.c プロジェクト: 1stMaster/syslinux
/* Returns the status code from PXE (0 on success),
   or -1 on invocation failure */
int pxe_get_nic_type(t_PXENV_UNDI_GET_NIC_TYPE *gnt)
{
    com32sys_t regs;
    t_PXENV_UNDI_GET_NIC_TYPE *lgnt;

    lgnt = lzalloc(sizeof *lgnt);
    if (!lgnt)
	return -1;

    memset(&regs, 0, sizeof regs);
    regs.eax.w[0] = 0x0009;
    regs.ebx.w[0] = PXENV_UNDI_GET_NIC_TYPE;
    regs.es = SEG(lgnt);
    /* regs.edi.w[0] = OFFS(lgnt); */

    __intcall(0x22, &regs, &regs);

    memcpy(gnt, lgnt, sizeof(t_PXENV_UNDI_GET_NIC_TYPE));
    lfree(lgnt);

    if (regs.eflags.l & EFLAGS_CF)
	return -1;

    return gnt->Status;
}
コード例 #7
0
ファイル: buffer.c プロジェクト: carriercomm/alpine-1
/*
 * This routine blows away all of the text
 * in a buffer. If the buffer is marked as changed
 * then we ask if it is ok to blow it away; this is
 * to save the user the grief of losing text. The
 * window chain is nearly always wrong if this gets
 * called; the caller must arrange for the updates
 * that are required. Return TRUE if everything
 * looks good.
 */
int
bclear(BUFFER *bp)
{
        register LINE   *lp;
        register int    s = FALSE;

	if(Pmaster){
	    if ((bp->b_flag&BFTEMP) == 0 	/* Not scratch buffer.  */
		&& (bp->b_flag&BFCHG) != 0){	/* Something changed    */
		emlwrite("buffer lines not freed.", NULL);
		return (s);
	    }
	}
	else{
	    if ((bp->b_flag&BFTEMP) == 0	/* Not scratch buffer.  */
		&& (bp->b_flag&BFCHG) != 0	/* Something changed    */
		/* TRANSLATORS: A question asking whether to forget about
		   the changes and revert to the unchanged version. */
		&& (s=mlyesno_utf8(_("Discard changes"), -1)) != TRUE){
		return (s);
	    }
	}

        bp->b_flag  &= ~BFCHG;                  /* Not changed          */
        while ((lp=lforw(bp->b_linep)) != bp->b_linep)
                lfree(lp);
        bp->b_dotp  = bp->b_linep;              /* Fix "."              */
        bp->b_doto  = 0;
        bp->b_markp = NULL;                     /* Invalidate "mark"    */
        bp->b_marko = 0;
        return (TRUE);
}
コード例 #8
0
ファイル: tls.c プロジェクト: jasonbking/illumos-gate
/*
 * Grow the TLS module information array as necessary to include the
 * specified module-id.  tls_modinfo->tls_size must be a power of two.
 * Return a pointer to the (possibly reallocated) module information array.
 */
static TLS_modinfo *
tls_modinfo_alloc(tls_metadata_t *tlsm, ulong_t moduleid)
{
	tls_t *tls_modinfo = &tlsm->tls_modinfo;
	TLS_modinfo *modinfo;
	size_t mod_slots;

	if ((modinfo = tls_modinfo->tls_data) == NULL ||
	    tls_modinfo->tls_size <= moduleid) {
		if ((mod_slots = tls_modinfo->tls_size) == 0)
			mod_slots = MIN_MOD_SLOTS;
		while (mod_slots <= moduleid)
			mod_slots *= 2;
		modinfo = lmalloc(mod_slots * sizeof (TLS_modinfo));
		if (tls_modinfo->tls_data != NULL) {
			(void) memcpy(modinfo, tls_modinfo->tls_data,
			    tls_modinfo->tls_size * sizeof (TLS_modinfo));
			lfree(tls_modinfo->tls_data,
			    tls_modinfo->tls_size * sizeof (TLS_modinfo));
		}
		tls_modinfo->tls_data = modinfo;
		tls_modinfo->tls_size = mod_slots;
	}
	return (modinfo);
}
コード例 #9
0
ファイル: dired.c プロジェクト: Hiroyuki-Nagata/mona
/* ARGSUSED */
int
d_expunge(int f, int n)
{
	struct line	*lp, *nlp;
	char		 fname[NFILEN];

	for (lp = bfirstlp(curbp); lp != curbp->b_headp; lp = nlp) {
		nlp = lforw(lp);
		if (llength(lp) && lgetc(lp, 0) == 'D') {
			switch (d_makename(lp, fname, sizeof(fname))) {
			case ABORT:
				ewprintf("Bad line in dired buffer");
				return (FALSE);
			case FALSE:
				if (unlink(fname) < 0) {
					ewprintf("Could not delete '%s'",
					    basename(fname));
					return (FALSE);
				}
				break;
			case TRUE:
				if (rmdir(fname) < 0) {
					ewprintf("Could not delete directory '%s'",
					    basename(fname));
					return (FALSE);
				}
				break;
			}
			lfree(lp);
			curwp->w_bufp->b_lines--;
			curwp->w_flag |= WFFULL;
		}
	}
	return (TRUE);
}
コード例 #10
0
ファイル: spawn.c プロジェクト: NanXiao/illumos-joyent
int
posix_spawn_file_actions_addopen(
	posix_spawn_file_actions_t *file_actions,
	int filedes,
	const char *path,
	int oflag,
	mode_t mode)
{
	file_attr_t *fap;

	if (filedes < 0)
		return (EBADF);
	if ((fap = lmalloc(sizeof (*fap))) == NULL)
		return (ENOMEM);

	fap->fa_pathsize = strlen(path) + 1;
	if ((fap->fa_path = lmalloc(fap->fa_pathsize)) == NULL) {
		lfree(fap, sizeof (*fap));
		return (ENOMEM);
	}
	(void) strcpy(fap->fa_path, path);

	fap->fa_type = FA_OPEN;
	fap->fa_oflag = oflag;
	fap->fa_mode = mode;
	fap->fa_filedes = filedes;
	add_file_attr(file_actions, fap);

	return (0);
}
コード例 #11
0
ファイル: mpatch.c プロジェクト: Distrotech/mercurial
/* decode a binary patch into a hunk list */
static struct flist *decode(const char *bin, Py_ssize_t len)
{
	struct flist *l;
	struct frag *lt;
	int pos = 0;

	/* assume worst case size, we won't have many of these lists */
	l = lalloc(len / 12);
	if (!l)
		return NULL;

	lt = l->tail;

	while (pos >= 0 && pos < len) {
		lt->start = getbe32(bin + pos);
		lt->end = getbe32(bin + pos + 4);
		lt->len = getbe32(bin + pos + 8);
		if (lt->start > lt->end)
			break; /* sanity check */
		lt->data = bin + pos + 12;
		pos += 12 + lt->len;
		lt++;
	}

	if (pos != len) {
		if (!PyErr_Occurred())
			PyErr_SetString(mpatch_Error, "patch cannot be decoded");
		lfree(l);
		return NULL;
	}

	l->tail = lt;
	return l;
}
コード例 #12
0
ファイル: buffer.c プロジェクト: WizardGed/mg
/*
 * The argument "fmt" points to a format string.  Append this line to the
 * buffer. Handcraft the EOL on the end.  Return TRUE if it worked and
 * FALSE if you ran out of room.
 */
int
addlinef(struct buffer *bp, char *fmt, ...)
{
	va_list		 ap;
	struct line	*lp;

	if ((lp = lalloc(0)) == NULL)
		return (FALSE);
	va_start(ap, fmt);
	if (vasprintf(&lp->l_text, fmt, ap) == -1) {
		lfree(lp);
		va_end(ap);
		return (FALSE);
	}
	lp->l_used = strlen(lp->l_text);
	va_end(ap);

	bp->b_headp->l_bp->l_fp = lp;		/* Hook onto the end	 */
	lp->l_bp = bp->b_headp->l_bp;
	bp->b_headp->l_bp = lp;
	lp->l_fp = bp->b_headp;
	bp->b_lines++;

	return (TRUE);
}
コード例 #13
0
ファイル: config.c プロジェクト: numascale/firmware
Config::Config(const char *filename)
{
	size_t len;
	printf("Config %s", filename);
	const char *data = os->read_file(filename, &len);
	assertf(data && len > 0, "Failed to open file");

	parse(data);
	lfree((char *)data);

	if (options->debug.config) {
		printf("\n");

		for (unsigned i = 0; i < nnodes; i++) {
			printf("Node %u: hostname %s%02u, MAC %02x:%02x:%02x:%02x:%02x:%02x, ",
			  i, prefix, nodes[i].id, nodes[i].mac[0], nodes[i].mac[1], nodes[i].mac[2],
			  nodes[i].mac[3], nodes[i].mac[4], nodes[i].mac[5]);

			printf("%03x, ", nodes[i].id);
			printf("partition %u (%sunified)\n", nodes[i].partition, partitions[nodes[i].partition].unified ? "" : "non-");
		}
	}

	// find local MAC address
	for (unsigned i = 0; i < nnodes; i++) {
		if (!memcmp(os->mac, nodes[i].mac, sizeof(os->mac))) {
			if (options->debug.config)
				printf("MAC matches node %u", i);
			local_node = &nodes[i];
			break;
		}
	}

	assertf(local_node, "Failed to find entry matching this node with UUID, MAC address or hostname");

	// ensure master occurs 0 or 1 times in this partition
	unsigned count = 0;

	for (unsigned i = 0; i < nnodes; i++) {
		if (local_node->partition == nodes[i].partition && nodes[i].master) {
			master = &nodes[i];
			count++;
		}
	}

	assertf(count <= 1, "More than one node specified as master in partition %u", local_node->partition);

	// if not specfied, select first node in this partition as master
	if (count == 0) {
		for (unsigned i = 0; i < nnodes; i++) {
			if (local_node->partition == nodes[i].partition) {
				nodes[i].master = 1;
				master = &nodes[i];
				break;
			}
		}
	}

	printf("; partition %u %sunified; %03x; %s\n", local_node->partition, partitions[local_node->partition].unified ? "" : "non-", local_node->id, local_node->master ? "master" : "slave");
}
コード例 #14
0
ファイル: syslinux.c プロジェクト: numascale/firmware
int OS::udp_read(void *buf, const size_t len, uint32_t *from_ip)
{
	int ret = 0;

	t_PXENV_UDP_READ *pxe_read_param = (t_PXENV_UDP_READ *)lzalloc(sizeof(t_PXENV_UDP_READ) + len);
	xassert(pxe_read_param);
	char *buf_reloc = (char *)pxe_read_param + sizeof(*pxe_read_param);

	pxe_read_param->s_port = htons(UDP_PORT_NO);
	pxe_read_param->d_port = htons(UDP_PORT_NO);
	pxe_read_param->buffer.seg = SEG(buf_reloc);
	pxe_read_param->buffer.offs = OFFS(buf_reloc);
	pxe_read_param->buffer_size = len;
	pxeapi_call(PXENV_UDP_READ, (uint8_t *)pxe_read_param);

	if ((pxe_read_param->status == PXENV_STATUS_SUCCESS) &&
	    (pxe_read_param->s_port == htons(UDP_PORT_NO))) {
		memcpy(buf, buf_reloc, pxe_read_param->buffer_size);
		*from_ip = pxe_read_param->src_ip;
		ret = pxe_read_param->buffer_size;
	}

	lfree(pxe_read_param);
	return ret;
}
コード例 #15
0
ファイル: ludis.c プロジェクト: simonz05/ludis
/* build a new command by concencate an array 
*  which contains the arguments for the command 
*  returns the len of the command */
int 
format_argv(Str **dest, struct command *cmd)
{
    int i, size;
    char buf[16];
    Str *out;

    cmd->len += 1 + int_len(cmd->argc) + 2;
    out = str_new(cmd->len);
    size = sprintf(buf, "*%d\r\n", cmd->argc);
    out = str_append(out, buf, size);

    /* debug */
    /* printf("len:\t%d\n", cmd->len);
    printf("argc:\t%d\n", cmd->argc);
    printf("data:\t%s\n", out->data); */

    for (i = 0; i < cmd->argc; i++) {
        size = sprintf(buf, "$%d\r\n", cmd->argv[i]->len);
        out = str_append(out, buf, size);
        out = str_cat(out, cmd->argv[i]);
        out = str_append(out, "\r\n", 2);
        str_free(cmd->argv[i]);
    }

    lfree(cmd->argv);
    assert(str_len(out) == cmd->len);
    *dest = out;

    /* debug */
    /*log_proto(out->data);*/
    
    return cmd->len;
}
コード例 #16
0
ファイル: List.c プロジェクト: jimmyjames85/coms352
void lfreefree(List * list)
{
     if(list==NULL)
	  return;
     int i=0;
     for(i=0;i<list->length;i++)
	  free(list->arr[i]);
     lfree(list);
}
コード例 #17
0
ファイル: localeimpl.c プロジェクト: dlethe/illumos-gate
/*
 * Normally we never free locale data truly, but if we failed to load it
 * for some reason, this routine is used to cleanup the partial mess.
 */
void
__locdata_free(struct locdata *ldata)
{
	for (int i = 0; i < NLOCDATA; i++)
		libc_free(ldata->l_data[i]);
	if (ldata->l_map != NULL && ldata->l_map_len)
		(void) munmap(ldata->l_map, ldata->l_map_len);
	lfree(ldata, sizeof (*ldata));
}
コード例 #18
0
ファイル: pthr_rwlock.c プロジェクト: andreiw/polaris
int
_pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr)
{
	if (attr == NULL || attr->__pthread_rwlockattrp == NULL)
		return (EINVAL);
	lfree(attr->__pthread_rwlockattrp, sizeof (rwlattr_t));
	attr->__pthread_rwlockattrp = NULL;
	return (0);
}
コード例 #19
0
ファイル: use.c プロジェクト: 8l/myrddin
static void fixtypemappings(Stab *st)
{
    size_t i;
    Type *t, *old;


    /*
     * merge duplicate definitions.
     * This allows us to compare named types by id, instead
     * of doing a deep walk through the type. This ability is
     * depended on when we do type inference.
     */
    for (i = 0; i < ntypefixdest; i++) {
        t = htget(tidmap, itop(typefixid[i]));
        if (!t)
            die("Unable to find type for id %zd\n", typefixid[i]);
        *typefixdest[i] = t;
    }
    for (i = 0; i < ntypefixdest; i++) {
        old = *typefixdest[i];
        if (old->type == Tyname || old->type == Tygeneric) {
            t = htget(tydedup, old);
            if (!t) {
                t = old;
                htput(tydedup, old, old);
            }
            *typefixdest[i] = t;
        }
    }

    /* check for duplicate type definitions */
    for (i = 0; i < ntypefixdest; i++) {
        t = htget(tidmap, itop(typefixid[i]));
        if ((t->type != Tyname && t->type != Tygeneric) || t->issynth)
            continue;
        old = htget(tydedup, t);
        if (old && !tyeq(t, old) && !isspecialization(t, old))
            lfatal(t->loc, "Duplicate definition of type %s on %s:%d", tystr(old), file->file.files[old->loc.file], old->loc.line);
    }
    for (i = 0; i < ntypefixdest; i++) 
    lfree(&typefixdest, &ntypefixdest);
    lfree(&typefixid, &ntypefixid);
}
コード例 #20
0
ファイル: undo.c プロジェクト: OS2World/APP-EDITOR-Vile
/* clean the copied flag on the line we're the copy of */
void
freeundostacks(BUFFER *bp, int both)
{
    LINE *lp;

    TRACE((T_CALLED "freeundostacks(%p,%d)\n", (void *) bp, both));
    while ((lp = popline(FORWSTK(bp), TRUE)) != NULL) {
	lfree(lp, bp);
    }
    if (both) {
	while ((lp = popline(BACKSTK(bp), TRUE)) != NULL) {
	    lfree(lp, bp);
	}
	bp->b_udtail = 0;
	bp->b_udlastsep = 0;
	bp->b_udcount = 0;
    }
    returnVoid();
}
コード例 #21
0
ファイル: spawn.c プロジェクト: NanXiao/illumos-joyent
int
posix_spawn_file_actions_destroy(
	posix_spawn_file_actions_t *file_actions)
{
	file_attr_t *froot = file_actions->__file_attrp;
	file_attr_t *fap;
	file_attr_t *next;

	if ((fap = froot) != NULL) {
		do {
			next = fap->fa_next;
			if (fap->fa_type == FA_OPEN)
				lfree(fap->fa_path, fap->fa_pathsize);
			lfree(fap, sizeof (*fap));
		} while ((fap = next) != froot);
	}
	file_actions->__file_attrp = NULL;
	return (0);
}
コード例 #22
0
static void dump_e820(void)
{
    com32sys_t ireg, oreg;
    struct e820_data ed;
    uint32_t type;
    void *low_ed;

    low_ed = lmalloc(sizeof ed);
    if (!low_ed)
        return;

    memset(&ireg, 0, sizeof ireg);

    ireg.eax.w[0] = 0xe820;
    ireg.edx.l = 0x534d4150;
    ireg.ecx.l = sizeof(struct e820_data);
    ireg.edi.w[0] = OFFS(low_ed);
    ireg.es = SEG(low_ed);

    memset(&ed, 0, sizeof ed);
    ed.extattr = 1;

    do {
        memcpy(low_ed, &ed, sizeof ed);

        __intcall(0x15, &ireg, &oreg);
        if (oreg.eflags.l & EFLAGS_CF ||
                oreg.eax.l != 0x534d4150 || oreg.ecx.l < 20)
            break;

        memcpy(&ed, low_ed, sizeof ed);

        if (oreg.ecx.l >= 24) {
            /* ebx base length end type */
            printf("%8x %016llx %016llx %016llx %d [%x]",
                   ireg.ebx.l, ed.base, ed.len, ed.base + ed.len, ed.type,
                   ed.extattr);
        } else {
            /* ebx base length end */
            printf("%8x %016llx %016llx %016llx %d [-]",
                   ireg.ebx.l, ed.base, ed.len, ed.base + ed.len, ed.type);
            ed.extattr = 1;
        }

        type = ed.type - 1;
        if (type < sizeof(e820_types) / sizeof(e820_types[0]))
            printf(" %s", e820_types[type]);

        putchar('\n');

        ireg.ebx.l = oreg.ebx.l;
    } while (ireg.ebx.l);

    lfree(low_ed);
}
コード例 #23
0
ファイル: localeimpl.c プロジェクト: dlethe/illumos-gate
void
freelocale(locale_t loc)
{
	/*
	 * We take extra care never to free a saved locale created by
	 * setlocale().  This shouldn't be strictly necessary, but a little
	 * extra safety doesn't hurt here.
	 */
	if ((loc != NULL) && (loc != &posix_locale) && (!loc->on_list))
		lfree(loc, sizeof (*loc));
}
コード例 #24
0
ファイル: rwlock.c プロジェクト: NanXiao/illumos-joyent
/*
 * Free the array of rwlocks held for reading.
 */
void
rwl_free(ulwp_t *ulwp)
{
	uint_t nlocks;

	if ((nlocks = ulwp->ul_rdlockcnt) != 0)
		lfree(ulwp->ul_readlock.array, nlocks * sizeof (readlock_t));
	ulwp->ul_rdlockcnt = 0;
	ulwp->ul_readlock.single.rd_rwlock = NULL;
	ulwp->ul_readlock.single.rd_count = 0;
}
コード例 #25
0
ファイル: thread_pool.c プロジェクト: andreiw/polaris
void
postfork1_child_tpool(void)
{
	pthread_t my_tid = pthread_self();
	tpool_t *tpool;
	tpool_job_t *job;

	/*
	 * All of the thread pool workers are gone, except possibly
	 * for the current thread, if it is a thread pool worker thread.
	 * Retain the thread pools, but make them all empty.  Whatever
	 * jobs were queued or running belong to the parent process.
	 */
top:
	if ((tpool = thread_pools) == NULL)
		return;

	do {
		tpool_active_t *activep;

		(void) mutex_init(&tpool->tp_mutex, USYNC_THREAD, NULL);
		(void) cond_init(&tpool->tp_busycv, USYNC_THREAD, NULL);
		(void) cond_init(&tpool->tp_workcv, USYNC_THREAD, NULL);
		(void) cond_init(&tpool->tp_waitcv, USYNC_THREAD, NULL);
		for (job = tpool->tp_head; job; job = tpool->tp_head) {
			tpool->tp_head = job->tpj_next;
			lfree(job, sizeof (*job));
		}
		tpool->tp_tail = NULL;
		tpool->tp_njobs = 0;
		for (activep = tpool->tp_active; activep;
		    activep = activep->tpa_next) {
			if (activep->tpa_tid == my_tid) {
				activep->tpa_next = NULL;
				break;
			}
		}
		tpool->tp_idle = 0;
		tpool->tp_current = 0;
		if ((tpool->tp_active = activep) != NULL)
			tpool->tp_current = 1;
		tpool->tp_flags &= ~TP_WAIT;
		if (tpool->tp_flags & (TP_DESTROY | TP_ABANDON)) {
			tpool->tp_flags &= ~TP_DESTROY;
			tpool->tp_flags |= TP_ABANDON;
			if (tpool->tp_current == 0) {
				delete_pool(tpool);
				goto top;	/* start over */
			}
		}
	} while ((tpool = tpool->tp_forw) != thread_pools);
}
コード例 #26
0
ファイル: mpatch.c プロジェクト: Distrotech/mercurial
/* combine hunk lists a and b, while adjusting b for offset changes in a/
   this deletes a and b and returns the resultant list. */
static struct flist *combine(struct flist *a, struct flist *b)
{
	struct flist *c = NULL;
	struct frag *bh, *ct;
	int offset = 0, post;

	if (a && b)
		c = lalloc((lsize(a) + lsize(b)) * 2);

	if (c) {

		for (bh = b->head; bh != b->tail; bh++) {
			/* save old hunks */
			offset = gather(c, a, bh->start, offset);

			/* discard replaced hunks */
			post = discard(a, bh->end, offset);

			/* insert new hunk */
			ct = c->tail;
			ct->start = bh->start - offset;
			ct->end = bh->end - post;
			ct->len = bh->len;
			ct->data = bh->data;
			c->tail++;
			offset = post;
		}

		/* hold on to tail from a */
		memcpy(c->tail, a->head, sizeof(struct frag) * lsize(a));
		c->tail += lsize(a);
	}

	lfree(a);
	lfree(b);
	return c;
}
コード例 #27
0
ファイル: kinsol.c プロジェクト: cvoter/Parflow
void KINFree(void *kinsol_mem)
{
  KINMem kin_mem;

  kin_mem = (KINMem)kinsol_mem;

  if (kinsol_mem == NULL)
    return;

  KINFreeVectors(kin_mem);

  if (kin_mem != NULL)
    lfree(kin_mem);
  free(kin_mem);
}
コード例 #28
0
ファイル: tls.c プロジェクト: jasonbking/illumos-gate
/*
 * We only free the dynamically allocated TLS; the statically
 * allocated TLS is reused when the ulwp_t is reallocated.
 */
void
tls_free(ulwp_t *ulwp)
{
	ulong_t moduleid;
	tls_t *tlsent;
	size_t ntlsent;
	void *base;
	size_t size;

	if ((tlsent = ulwp->ul_tlsent) == NULL ||
	    (ntlsent = ulwp->ul_ntlsent) == 0)
		return;

	for (moduleid = 0; moduleid < ntlsent; moduleid++, tlsent++) {
		if ((base = tlsent->tls_data) != NULL &&
		    (size = tlsent->tls_size) != 0)
			lfree(base, size);
		tlsent->tls_data = NULL;	/* paranoia */
		tlsent->tls_size = 0;
	}
	lfree(ulwp->ul_tlsent, ntlsent * sizeof (tls_t));
	ulwp->ul_tlsent = NULL;
	ulwp->ul_ntlsent = 0;
}
コード例 #29
0
ファイル: edmain.c プロジェクト: ricksladkey/CLIPS
globle int spec_clear(
  void *theEnv,
  BUFFER *bp)
{
        register LINE   *lp;

        bp->b_flag  &= ~BFCHG;                  /* Not changed          */
        while ((lp=lforw(bp->b_linep)) != bp->b_linep)
                lfree(theEnv,lp);
        bp->b_dotp  = bp->b_linep;              /* Fix "."              */
        bp->b_doto  = 0;
        bp->b_markp = NULL;                     /* Invalidate "mark"    */
        bp->b_marko = 0;
        return (TRUE);
}
コード例 #30
0
ファイル: use.c プロジェクト: 8l/myrddin
static void fixtraitmappings(Stab *st)
{
    size_t i;
    Trait *t;

    /*
     * merge duplicate definitions.
     * This allows us to compare named types by id, instead
     * of doing a deep walk through the type. This ability is
     * depended on when we do type inference.
     */
    for (i = 0; i < ntraitfixdest; i++) {
        t = htget(trmap, itop(traitfixid[i]));
        if (!t)
            die("Unable to find trait for id %zd\n", traitfixid[i]);
        if (traitfixdest[i])
            *traitfixdest[i] = t;
        if (traitfixtype[i])
            settrait(traitfixtype[i], t);
    }

    lfree(&traitfixdest, &ntraitfixdest);
    lfree(&traitfixid, &ntraitfixid);
}