예제 #1
0
void ui_menudestroy(ui_widget_t* widget)
{
	ui_menudata_t* data=(ui_menudata_t*)widget->data;
	if(data->positions)
		sys_free(data->positions);
	sys_free(data);
}
예제 #2
0
void __attribute__((destructor)) __ibprof_exit(void)
{
	IBPROF_ERROR status = IBPROF_ERR_NONE;
	UNREFERENCED_PARAMETER(status);

	/* check if it has been activated */
	if (ibprof_obj) {
		IBPROF_MODULE_OBJECT *temp_module_obj = NULL;
		int i = 0;

		ibprof_obj->task_obj->wall_time =
			ibprof_task_wall_time(ibprof_obj->task_obj->t_start);

		/* Dump all gathered information */
		ibprof_dump();

		temp_module_obj = ibprof_obj->module_array[0];
		while (temp_module_obj) {
			if (temp_module_obj->id != IBPROF_MODULE_INVALID) {
				if (temp_module_obj->exit)
					status = temp_module_obj->exit(temp_module_obj);
			}
			temp_module_obj = ibprof_obj->module_array[++i];
		}

		ibprof_hash_destroy(ibprof_obj->hash_obj);

		ibprof_task_destroy(ibprof_obj->task_obj);

		DELETE_CRITICAL(&(ibprof_obj->lock));

		sys_free(ibprof_obj);
		ibprof_obj = NULL;
	}

	if (ibprof_dump_file &&
		ibprof_dump_file != stdout &&
		ibprof_dump_file != stderr) {

		struct stat     statbuf;
		char fd_path[255];
		char *filename = sys_malloc(255);
		size_t ret = 0;

		sys_sprintf(fd_path, "/proc/self/fd/%d", fileno(ibprof_dump_file));

		ret = readlink(fd_path, filename, 255);

		if (ret > 0) {
			sys_fflush(ibprof_dump_file);
			sys_fclose(ibprof_dump_file);
			if (!sys_fstat(filename, &statbuf))
				if (!statbuf.st_size)
					  ret = sys_fremove(filename);
		}
	        sys_free(filename);
	}

	return ;
}
예제 #3
0
void chpl_comm_ofi_oob_allgather(const void* mine, void* all, size_t size) {
  DBG_PRINTF(DBG_OOB, "OOB allGather: %zd", size);

  //
  // PMI doesn't provide an ordered allGather, so we build one here
  // by concatenating the node index and the payload and using that
  // to scatter the unordered PMI_Allgather() results.
  //
  typedef struct {
    int nodeID;
    uint64_t info[];
  } gather_t;

  const size_t g_size = offsetof(gather_t, info) + size;
  gather_t* g_mine;
  CHK_SYS_CALLOC_SZ(g_mine, 1, g_size);
  g_mine->nodeID = chpl_nodeID;
  memcpy(&g_mine->info, mine, size);

  gather_t* g_all;
  CHK_SYS_CALLOC_SZ(g_all, chpl_numNodes, g_size);

  PMI_CHK(PMI_Allgather(g_mine, g_all, g_size));

  for (int g_i = 0; g_i < chpl_numNodes; g_i++) {
    char* g_pa = (char*) g_all + g_i * g_size;
    int i;
    memcpy(&i, g_pa + offsetof(gather_t, nodeID), sizeof(i));
    char* p_a = (char*) all + i * size;
    memcpy(p_a, g_pa + offsetof(gather_t, info), size);
  }

  sys_free(g_all);
  sys_free(g_mine);
}
예제 #4
0
void sys_freelist(char** list)
{
	unsigned int i;
	for(i=0;list[i];i++)
		sys_free(list[i]);
	sys_free(list);
}
예제 #5
0
파일: dir.c 프로젝트: descent/elephant
/* 在part分区内的pdir目录内寻找名为name的文件或目录,
 * 找到后返回true并将其目录项存入dir_e,否则返回false */
bool search_dir_entry(struct partition* part, struct dir* pdir, \
		     const char* name, struct dir_entry* dir_e) {
   uint32_t block_cnt = 140;	 // 12个直接块+128个一级间接块=140块

   /* 12个直接块大小+128个间接块,共560字节 */
   uint32_t* all_blocks = (uint32_t*)sys_malloc(48 + 512);
   if (all_blocks == NULL) {
      printk("search_dir_entry: sys_malloc for all_blocks failed");
      return false;
   }

   uint32_t block_idx = 0;
   while (block_idx < 12) {
      all_blocks[block_idx] = pdir->inode->i_sectors[block_idx];
      block_idx++;
   }
   block_idx = 0;

   if (pdir->inode->i_sectors[12] != 0) {	// 若含有一级间接块表
      ide_read(part->my_disk, pdir->inode->i_sectors[12], all_blocks + 12, 1);
   }
/* 至此,all_blocks存储的是该文件或目录的所有扇区地址 */

   /* 写目录项的时候已保证目录项不跨扇区,
    * 这样读目录项时容易处理, 只申请容纳1个扇区的内存 */
   uint8_t* buf = (uint8_t*)sys_malloc(SECTOR_SIZE);
   struct dir_entry* p_de = (struct dir_entry*)buf;	    // p_de为指向目录项的指针,值为buf起始地址
   uint32_t dir_entry_size = part->sb->dir_entry_size;
   uint32_t dir_entry_cnt = SECTOR_SIZE / dir_entry_size;   // 1扇区内可容纳的目录项个数

   /* 开始在所有块中查找目录项 */
   while (block_idx < block_cnt) {		  
   /* 块地址为0时表示该块中无数据,继续在其它块中找 */
      if (all_blocks[block_idx] == 0) {
	 block_idx++;
	 continue;
      }
      ide_read(part->my_disk, all_blocks[block_idx], buf, 1);

      uint32_t dir_entry_idx = 0;
      /* 遍历扇区中所有目录项 */
      while (dir_entry_idx < dir_entry_cnt) {
	 /* 若找到了,就直接复制整个目录项 */
	 if (!strcmp(p_de->filename, name)) {
	    memcpy(dir_e, p_de, dir_entry_size);
	    sys_free(buf);
	    sys_free(all_blocks);
	    return true;
	 }
	 dir_entry_idx++;
	 p_de++;
      }
      block_idx++;
      p_de = (struct dir_entry*)buf;  // 此时p_de已经指向扇区内最后一个完整目录项了,需要恢复p_de指向为buf
      memset(buf, 0, SECTOR_SIZE);	  // 将buf清0,下次再用
   }
   sys_free(buf);
   sys_free(all_blocks);
   return false;
}
예제 #6
0
void hashtab_destroy(struct hashtab *h)
{
	int i;
	struct hashtab_node *cur, *temp;

	if (!h)
		return;

	for (i = 0; i < h->size; i++) {
		cur = h->htable[i];
		while (cur) {
			temp = cur;
			cur = cur->next;
			//kfree(temp);
			sys_free(temp);
		}
		h->htable[i] = NULL;
	}

	//kfree(h->htable);
	sys_free(h->htable);
	h->htable = NULL;

	//kfree(h);
	sys_free(h);
}
예제 #7
0
void sys_onUnload()
{
    sys_free(_ctxFile);
    sys_free(_glbFile);
    sys_free(_cfgFile);
    sys_free(_cfgDir);
}
예제 #8
0
void main ()
{
	video_mode = 8;
	fps_max = 60;
	wait(2);
	bmap_zbuffer ( bmap_createblack(2048,2048,32) );
	mouse_mode = 4;
	mouse_map = bmap_create ( "arrow_yellow.pcx" );
	vec_fill ( &screen_color, 128 );
	
	level_load ( "" );
	camera->pan = -40;
	camera->tilt = -30;
	evnCameraLocate ();
	vec_set ( &colCameraBG, vector(150,150,150) );
	camera->bg = pixel_for_vec ( &colCameraBG, 100, 8888 );
	
	ENTITY *ent = ent_create ( CUBE_MDL, nullvector, NULL );
	
	// Create style for the menues
	// CMMEMBER *myMenuStyle = cmstyle_create ( FONT *font, COLOR *colText, COLOR *colBack, COLOR *colOver )
	FONT *fntTTF = font_create("Arial#16");
	CMStyle *myMenuStyle01 = cmstyle_create ( fntTTF, vector(40,40,40), vector(250,250,250), vector(210,210,210) );
	FONT *fntBitmap = font_create("ackfont.pcx");
	CMStyle *myMenuStyle02 = cmstyle_create ( fntBitmap, vector(170,170,255), vector(30,20,0), vector(0,0,185) );
	
	// Create a compact menu panel
	// PANEL *cmenu_create ( char *chrMember, var pos_x, var pos_y, var size_x, var layer, var flags, CMStyle *style )
	PANEL *myMenu01 = cmenu_create ( "menu name.submenu=txtMain", 110, 20, 200, 1, SHOW, myMenuStyle01 );
	PANEL *myMenu02 = cmenu_create ( "debug & statics.submenu=txtCMDebug", 500, 20, 200, 1, SHOW, myMenuStyle01 );
	
	cmenu_modify ( myMenu02, 120, myMenuStyle02 );
	
	bmpSky = bmap_create ( "sky_fu_256+6.tga" );
	
	while ( !key_esc && !nExit )
	{
		str_setchr ( strString, 1, random(32)+32 );
		wait(1);
	}
	
	bmap_remove ( bmpSky );
	bmpSky = NULL;
	bmap_remove ( mouse_map );
	mouse_map = NULL;
	
	cmenu_remove ( myMenu01 );
	sys_free ( myMenuStyle01 ); 
	font_remove ( fntTTF );
	
	cmenu_remove ( myMenu02 );
	sys_free ( myMenuStyle02 );
	font_remove ( fntBitmap ); 
	
	sys_exit ( NULL );

}
예제 #9
0
void mt_destroydivider(mt_divider_t* divider)
{
	if(divider->query)
		sys_free(divider->query);
	mt_destroynode(divider->root);
	sys_free(divider->root);
	if(divider->colliders)
		sys_free(divider->colliders);
	sys_free(divider);
}
예제 #10
0
파일: trash.c 프로젝트: Acknex/TUST
void trash_close ()
{
	TrashItem *it = itTrash->first;
	for ( ; it != NULL; )
	{
		TrashItem *next = it->next;
		sys_free ( it->data );
		sys_free ( it );
		it = next;
	}
}
예제 #11
0
파일: inifile.c 프로젝트: miaofng/ulp
/**
*@brief read string in initialization file\n
* retrieves a string from the specified section in an initialization file
*@param section [in] name of the section containing the key name
*@param key [in] name of the key pairs to value 
*@param value [in] pointer to the buffer that receives the retrieved string
*@param size [in] size of result's buffer 
*@param default_value [in] default value of result
*@param file [in] path of the initialization file
*@return 1 : read success; \n 0 : read fail
*/
int read_profile_string( const char *section, const char *key,char *value, 
		 int size, const char *default_value, const char *file)
{
	char *buf;
	int file_size;
	int sec_s,sec_e,key_s,key_e, value_s, value_e;

	//check parameters
	assert(section != NULL && strlen(section));
	assert(key != NULL && strlen(key));
	assert(value != NULL);
	assert(size > 0);
	assert(file !=NULL &&strlen(key));

	buf = (char *)sys_malloc(MAX_FILE_SIZE);
	memset(buf,0,MAX_FILE_SIZE);

	if(!load_ini_file(file,buf,&file_size))
	{
		if(default_value!=NULL)
		{
			strncpy(value,default_value, size);
		}
		sys_free(buf);
		return 0;
	}

	if(!parse_file(section,key,buf,&sec_s,&sec_e,&key_s,&key_e,&value_s,&value_e))
	{
		if(default_value!=NULL)
		{
			strncpy(value,default_value, size);
		}
		sys_free(buf);
		return 0; //not find the key
	}
	else
	{
		int cpcount = value_e -value_s;

		if( size-1 < cpcount)
		{
			cpcount =  size-1;
		}
	
		memset(value, 0, size);
		memcpy(value,buf+value_s, cpcount );
		value[cpcount] = '\0';

		sys_free(buf);

		return 1;
	}
}
예제 #12
0
파일: adlist.c 프로젝트: fxding/rwcached
void decrRefCount(void *obj){
	object *o = obj;


	if (o->refcount <= 0) xlog(LOG_WARN, "decrRefCount 一个对象的引用计数 <= 0\n");
	if (o->refcount == 1){
		sys_free(o->ptr);
		sys_free(o);
		xlog(LOG_DEBUG, "decr : 释放一个节点\n");
	} else {
		o->refcount--;
	}
}
예제 #13
0
static void clntudp_destroy(CLIENT *cl)
{
	register struct cu_data *cu = (struct cu_data *) cl->cl_private;

	if (cu->cu_closeit)
	{
		close(cu->cu_sock);
	}

	XDR_DESTROY(&(cu->cu_outxdrs));
	sys_free(cu);
	sys_free(cl);
}
예제 #14
0
파일: adlist.c 프로젝트: fxding/rwcached
/* Free the whole list.
 *
 * This function can't fail. */
void listRelease(list *list)
{
    unsigned int len;
    listNode *current, *next;

    current = list->head;
    len = list->len;
    while(len--) {
        next = current->next;
        if (list->free) list->free(current->value);
        sys_free(current);
        current = next;
    }
    sys_free(list);
}
예제 #15
0
static void mt_destroynode(mt_dividernode_t* node)
{
	if(node->colliders)
		sys_free(node->colliders);

	if(node->children)
	{
		int i;

		//Destroy children
		for(i=0;i<8;i++)
			mt_destroynode(&node->children[i]);

		sys_free(node->children);
	}
}
예제 #16
0
파일: osd_draw.c 프로젝트: miaofng/ulp
int item_DrawTxt(const osd_item_t *item, int status)
{
	const char *str;
	char *buf;
	size_t len;
	int x;
	int (*get_value)(void);

	//get string value
	str = (const char *) item->v;
	if(item->runtime & ITEM_RUNTIME_V) {
		get_value = (int (*)(void)) item->v;
		str = (const char *) get_value();
	}

	//string width limit
	len = strlen(str);
	len = (len > item->w) ? item->w : len;
	buf = sys_malloc(len + 1);
	strncpy(buf, str, len);
	buf[len] = 0;

	//align
	x = item->x;
	x += (item->option & ITEM_ALIGN_MIDDLE) ? (item->w - len) >> 1 : 0;
	x += (item->option & ITEM_ALIGN_RIGHT) ? (item->w - len) : 0;

	//output to lcd
	osd_eng_puts(x, item->y, buf);

	sys_free(buf);
	return 0;
}
예제 #17
0
파일: uart_stm32.c 프로젝트: aarzho/mkernel
void uart_disable(UART_CLASS port)
{
	if (port < UARTS_COUNT)
	{
		//disable interrupts
		NVIC_DisableIRQ(UART_IRQ_VECTORS[port]);

		//disable core
		USART[port]->CR1 &= ~USART_CR1_UE;
		//power down
		if (port == UART_1 || port == UART_6)
			RCC->APB2ENR &= ~RCC_UART[port];
		else
			RCC->APB1ENR &= ~RCC_UART[port];

		//disable pins
		if ((USART_TX_DISABLE_MASK & (1 << port)) == 0)
			gpio_disable_pin(UART_TX_PINS[port]);
		if ((USART_RX_DISABLE_MASK & (1 << port)) == 0)
			gpio_disable_pin(UART_RX_PINS[port]);

#if (USART_REMAP_MASK)
		if ((1 << port) & USART_REMAP_MASK)
			afio_unmap();
#endif //USART_REMAP_MASK

		sys_free(_uart_handlers[port]);
		_uart_handlers[port] = NULL;
	}
	else
		error_dev(ERROR_DEVICE_INDEX_OUT_OF_RANGE, DEV_UART, port);
}
예제 #18
0
파일: dbg_gdb.c 프로젝트: smillaedler/rr
void dbg_reply_get_thread_list(struct dbg_context* dbg,
                               const dbg_threadid_t* threads, size_t len)
{
    assert(DREQ_GET_THREAD_LIST == dbg->req.type);

    if (0 == len) {
        write_packet(dbg, "l");
    } else {
        size_t maxlen =	1/*m char*/ +
                        (2 * sizeof(pid_t) + 1/*,*/) * len +
                        1/*\0*/;
        char* str = sys_malloc(maxlen);
        int i, offset = 0;

        str[offset++] = 'm';
        for (i = 0; i < len; ++i) {
            offset += snprintf(&str[offset], maxlen - offset,
                               "%02x,", threads[i]);
        }
        /* Overwrite the trailing ',' */
        str[offset - 1] = '\0';

        write_packet(dbg, str);
        sys_free((void**)&str);
    }

    consume_request(dbg);
}
예제 #19
0
파일: target.c 프로젝트: sjbiwa/bwos
void task1(void)
{
static void* ptr[100];
	int	ix;
	int count;
	for ( count=20; 0 < count; count-- ) {
		for (ix=0; ix<100; ix++) {
			ptr[ix] = sys_malloc_align(128, 8);
			//ptr[ix] = sys_malloc(128);
			lprintf("malloc1(8)[%d]=%08X\n", ix, ptr[ix]);
			if ( ptr[ix] ) {
				memset(ptr[ix], 0x11, 128);
			}
			task_tsleep(1);
		}
		for (ix=0; ix<100; ix++) {
			if ( ptr[ix] ) {
				lprintf("free1[%d]=%08X\n", ix, ptr[ix]);
				sys_free(ptr[ix]);
			}
			task_tsleep(1);
		}
		dump_space();
	}
	task_sleep();
}
예제 #20
0
파일: tun_drv.c 프로젝트: XinliNiu/jungerl
static void tun_stop(ErlDrvData data)
{
    struct tun_state *state = (struct tun_state *)data;
    set_input(state, 0);
    close(state->fd);
    sys_free(state);
}
예제 #21
0
파일: target.c 프로젝트: sjbiwa/bwos
void task2(void)
{
static void* ptr[100];
	int	ix;
	int count;
	for ( count=20; 0 < count; count-- ) {
		for (ix=0; ix<100; ix++) {
			ptr[ix] = sys_malloc_align(256, 16);
			//ptr[ix] = sys_malloc(256);
			lprintf("malloc2(16)[%d]=%08X\n", ix, ptr[ix]);
			if ( ptr[ix] ) {
				memset(ptr[ix], 0x44, 256);
			}
			task_tsleep(2);
		}
		for (ix=0; ix<100; ix++) {
			if ( ptr[ix] ) {
				lprintf("free2[%d]=%08X\n", ix, ptr[ix]);
				sys_free(ptr[ix]);
			}
			task_tsleep(2);
		}
		dump_space();
	}
	task_sleep();
}
예제 #22
0
파일: sys.c 프로젝트: smillaedler/rr
/**
** sys_mkpath - ensure all directories in path exist
** Algorithm takes the pessimistic view and works top-down to ensure
** each directory in path exists, rather than optimistically creating
** the last element and working backwards.
*/
int sys_mkpath(const char *path, mode_t mode)
{
    char           *pp;
    char           *sp;
    int             status;
    char           *copypath = sys_malloc(strlen(path) + 1);

    strcpy(copypath,path);
    status = 0;
    pp = copypath;
    while (status == 0 && (sp = strchr(pp, '/')) != 0)
    {
        if (sp != pp)
        {
            /* Neither root nor double slash in path */
            *sp = '\0';
            status = sys_mkdir(copypath, mode);
            *sp = '/';
        }
        pp = sp + 1;
    }

    sys_free((void**)&copypath);
    assert(status == 0);
    return status;
}
예제 #23
0
static void s1_ready_async(ErlDrvData drv_data, ErlDrvThreadData thread_data)
{
    descriptor_t        *desc = (descriptor_t *) drv_data;
    callstate_t *c = (callstate_t *) thread_data;
    int                 bytes, offset, i;
    char                *p = NULL;
    unsigned long       index = 0;

    edtk_debug("%s: cmd = %d", __FUNCTION__, c->cmd);
    if (c == NULL) {
        edtk_debug("%s: c == NULL", __FUNCTION__);
        return;
    }
    switch (c->cmd) {
    case S1_NULL:
        reply_ok(desc);
        break;
    case S1_OPEN:
        if (! c->o.__expect) {
            reply_error(desc, c->o.__expect_errval);
            break;
        }
        if (find_unused_fd_index(desc, &index) < 0) {
            reply_error(desc, ENOMEM);
        } else {
            desc->valmap_fd[index] = c->o.ret_int;
            reply_ok_valmap(desc, am_valmap_fd, index);
        }
        break;
    case S1_GETFD:
        reply_ok_num(desc, c->o.ret_int);
        break;
    case S1_SENDFD:
        if (c->o.__expect) {
            reply_ok_num(desc, c->o.ret_int_t);
        } else {
            reply_error(desc, c->o.__expect_errval);
        }
        break;
    case S1_RECEIVEFD:
        if (c->o.__expect) {
            reply_ok_num(desc, c->o.ret_int_t);
        } else {
            reply_error(desc, c->o.__expect_errval);
        }
        break;
    case S1_CLOSE:
        if (! c->o.__expect) {
            reply_error(desc, c->o.__expect_errval);
            break;
        }
        cleanup_valmap_fd_index(desc, c->i.__valmap_fd_index, 0);
        reply_ok_num(desc, c->o.ret_int);
        break;
    default:
        edtk_debug("%s: bogus command, should never happen", __FUNCTION__);
        break;
    }
    sys_free(c);
}
예제 #24
0
struct hashtab *hashtab_create(uint32 (*hash_value)(struct hashtab *h, const void *key, int len),
					uint32 (*hash_key)(struct hashtab *h, const void *key, int len),
					int (*keycmp)(struct hashtab *h, const void *key1, const void *key2),
					int size)
{
	struct hashtab *p;
	int i;

	//p = kzalloc(sizeof(*p), GFP_KERNEL);
	p = (struct hashtab*)sys_malloc(sizeof(*p));
	if (p == NULL)
		return p;

	p->size = size;
	p->nel = 0;
	p->hash_value = hash_value;
	p->hash_key = hash_key;
	p->keycmp = keycmp;
	p->htable = (struct hashtab_node **)sys_malloc(sizeof(*(p->htable)) * size);//kmalloc(sizeof(*(p->htable)) * size, GFP_KERNEL);
	if (p->htable == NULL) {
		//kfree(p);
		sys_free(p);
		return NULL;
	}

	for (i = 0; i < size; i++)
		p->htable[i] = NULL;

	return p;
}
예제 #25
0
파일: target.c 프로젝트: sjbiwa/bwos
void task3(void)
{
static void* ptr[100];
	int	ix;
	int count;
	for ( count=20; 0 < count; count-- ) {
		for (ix=0; ix<100; ix++) {
			ptr[ix] = sys_malloc_align(512, 64);
			//ptr[ix] = sys_malloc(512);
			lprintf("malloc3(64)[%d]=%08X\n", ix, ptr[ix]);
			if ( ptr[ix] ) {
				memset(ptr[ix], 0x77, 512);
			}
			task_tsleep(3);
		}
		for (ix=0; ix<100; ix++) {
			if ( ptr[ix] ) {
				lprintf("free3[%d]=%08X\n", ix, ptr[ix]);
				sys_free(ptr[ix]);
			}
			task_tsleep(3);
		}
		dump_space();
	}
	task_sleep();
}
예제 #26
0
int main(int argc, const char **argv) {
    printf("Running all tests...\n\n");

    int err;
    if ((err = setjmp(G_err))) {
    printf("ERROR: %d\n",err);
    }
    else {
    def_sys();
    //**** core tests
    testDef();
    testTree();
    testMTree();
    testStream();
    testLabel();
    testSemtrex();
    testReceptor();
    testProcess();
    testScape();
    testVMHost();
    testAccumulator();

    //***** examples
    testProfileExample();
    testHTTPExample();

    sys_free();
    report_tests();
    }
    pthread_exit(NULL);
    //    return 0;
}
예제 #27
0
static void
resizeTable(int direction) {
  memTableEntry** newMemTable = NULL;
  int newHashSizeIndex, newHashSize, newHashValue;
  int i;
  memTableEntry* me;
  memTableEntry* next;

  newHashSizeIndex = hashSizeIndex + direction;
  newHashSize = hashSizes[newHashSizeIndex];
  newMemTable = sys_calloc(newHashSize, sizeof(memTableEntry*));

  for (i = 0; i < hashSize; i++) {
    for (me = memTable[i]; me != NULL; me = next) {
      next = me->nextInBucket;
      newHashValue = hash(me->memAlloc, newHashSize);
      me->nextInBucket = newMemTable[newHashValue];
      newMemTable[newHashValue] = me;
    }
  }

  sys_free(memTable);
  memTable = newMemTable;
  hashSize = newHashSize;
  hashSizeIndex = newHashSizeIndex;
}
예제 #28
0
__attribute__ ((visibility("default"))) void
free(void* mem)
{
	if (mem != NULL)
		num_alloc--;
	sys_free(mem);
}
예제 #29
0
파일: ipc.c 프로젝트: sanyaade-mobiledev/rr
char* read_child_str(pid_t pid, long int addr)
{
	char *tmp, *str;
	int i, idx = 0;
	int buffer_size = 256;

	str = sys_malloc(buffer_size);

	while (1) {

		if (idx + READ_SIZE >= buffer_size) {
			buffer_size *= 2;
			str = realloc(str, buffer_size);
		}

		tmp = read_child_data_tid(pid, READ_SIZE, addr + idx);
		memcpy(str + idx, tmp, READ_SIZE);
		sys_free((void**) &tmp);

		for (i = 0; i < READ_SIZE; i++) {
			if (str[idx + i] == '\0') {
				return str;
			}
		}

		idx += READ_SIZE;
	}assert(1==0);
	return 0;
}
예제 #30
0
static void __config_exit( void )
{
    if (osh_config.exec_mode.log_file_name)
    {
        sys_free(osh_config.exec_mode.log_file_name);
    }
}