moved the heapsize parameter from hcl_open() to hcl_ignite()
This commit is contained in:
		| @ -735,7 +735,7 @@ int main (int argc, char* argv[]) | |||||||
| 	if (opt.ind >= argc) goto print_usage; | 	if (opt.ind >= argc) goto print_usage; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| 	hcl = hcl_openstd(HCL_SIZEOF(xtn_t), heapsize, HCL_NULL); | 	hcl = hcl_openstd(HCL_SIZEOF(xtn_t), HCL_NULL); | ||||||
| 	if (HCL_UNLIKELY(!hcl)) | 	if (HCL_UNLIKELY(!hcl)) | ||||||
| 	{ | 	{ | ||||||
| 		printf ("ERROR: cannot open hcl\n"); | 		printf ("ERROR: cannot open hcl\n"); | ||||||
| @ -786,7 +786,7 @@ int main (int argc, char* argv[]) | |||||||
| 	} | 	} | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| 	if (hcl_ignite(hcl) <= -1) | 	if (hcl_ignite(hcl, heapsize) <= -1) | ||||||
| 	{ | 	{ | ||||||
| 		hcl_logbfmt (hcl, HCL_LOG_STDERR, "cannot ignite hcl - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | 		hcl_logbfmt (hcl, HCL_LOG_STDERR, "cannot ignite hcl - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | ||||||
| 		goto oops; | 		goto oops; | ||||||
|  | |||||||
| @ -736,13 +736,13 @@ hcl_oop_t hcl_shallowcopy (hcl_t* hcl, hcl_oop_t oop) | |||||||
| /* ========================================================================= */ | /* ========================================================================= */ | ||||||
|  |  | ||||||
|  |  | ||||||
| int hcl_ignite (hcl_t* hcl) | int hcl_ignite (hcl_t* hcl, hcl_oow_t heapsize) | ||||||
| { | { | ||||||
| 	hcl_oow_t i; | 	hcl_oow_t i; | ||||||
|  |  | ||||||
| 	if (!hcl->heap) | 	if (!hcl->heap) | ||||||
| 	{ | 	{ | ||||||
| 		hcl->heap = hcl_makeheap(hcl, hcl->_reqheapsz); | 		hcl->heap = hcl_makeheap(hcl, heapsize); | ||||||
| 		if (HCL_UNLIKELY(!hcl->heap)) return -1; | 		if (HCL_UNLIKELY(!hcl->heap)) return -1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | |||||||
| @ -809,7 +809,7 @@ hcl_client_t* hcl_client_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_client_p | |||||||
| 		return HCL_NULL; | 		return HCL_NULL; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	hcl = hcl_openstdwithmmgr(mmgr, HCL_SIZEOF(*xtn), 2048, errnum); | 	hcl = hcl_openstdwithmmgr(mmgr, HCL_SIZEOF(*xtn), errnum); | ||||||
| 	if (!hcl)  | 	if (!hcl)  | ||||||
| 	{ | 	{ | ||||||
| 		HCL_MMGR_FREE (mmgr, client); | 		HCL_MMGR_FREE (mmgr, client); | ||||||
|  | |||||||
| @ -652,7 +652,7 @@ hcl_server_proto_t* hcl_server_proto_open (hcl_oow_t xtnsize, hcl_server_worker_ | |||||||
| 	proto->worker = worker; | 	proto->worker = worker; | ||||||
| 	proto->exec_runtime_event_index = HCL_TMR_INVALID_INDEX; | 	proto->exec_runtime_event_index = HCL_TMR_INVALID_INDEX; | ||||||
|  |  | ||||||
| 	proto->hcl = hcl_openstdwithmmgr(hcl_server_getmmgr(proto->worker->server), HCL_SIZEOF(*xtn), worker->server->cfg.actor_heap_size, HCL_NULL); | 	proto->hcl = hcl_openstdwithmmgr(hcl_server_getmmgr(proto->worker->server), HCL_SIZEOF(*xtn), HCL_NULL); | ||||||
| 	if (!proto->hcl) goto oops; | 	if (!proto->hcl) goto oops; | ||||||
|  |  | ||||||
| 	/* replace the vmprim.log_write function */ | 	/* replace the vmprim.log_write function */ | ||||||
| @ -680,7 +680,7 @@ hcl_server_proto_t* hcl_server_proto_open (hcl_oow_t xtnsize, hcl_server_worker_ | |||||||
| 	hclcb.vm_checkbc = vm_checkbc; | 	hclcb.vm_checkbc = vm_checkbc; | ||||||
| 	hcl_regcb (proto->hcl, &hclcb); | 	hcl_regcb (proto->hcl, &hclcb); | ||||||
|  |  | ||||||
| 	if (hcl_ignite(proto->hcl) <= -1) goto oops; | 	if (hcl_ignite(proto->hcl, worker->server->cfg.actor_heap_size) <= -1) goto oops; | ||||||
| 	if (hcl_addbuiltinprims(proto->hcl) <= -1) goto oops; | 	if (hcl_addbuiltinprims(proto->hcl) <= -1) goto oops; | ||||||
|  |  | ||||||
| 	if (hcl_attachio(proto->hcl, read_handler, print_handler) <= -1) goto oops; | 	if (hcl_attachio(proto->hcl, read_handler, print_handler) <= -1) goto oops; | ||||||
| @ -1508,7 +1508,7 @@ hcl_server_t* hcl_server_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_server_p | |||||||
| 		return HCL_NULL; | 		return HCL_NULL; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	hcl = hcl_openstdwithmmgr(mmgr, HCL_SIZEOF(*xtn), 2048, errnum); | 	hcl = hcl_openstdwithmmgr(mmgr, HCL_SIZEOF(*xtn), errnum); | ||||||
| 	if (!hcl) goto oops; | 	if (!hcl) goto oops; | ||||||
|  |  | ||||||
| 	/* replace the vmprim.log_write function */ | 	/* replace the vmprim.log_write function */ | ||||||
|  | |||||||
| @ -27,7 +27,7 @@ | |||||||
| #include "hcl-prv.h" | #include "hcl-prv.h" | ||||||
|  |  | ||||||
|  |  | ||||||
| hcl_t* hcl_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_oow_t heapsize, const hcl_vmprim_t* vmprim, hcl_errnum_t* errnum) | hcl_t* hcl_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, const hcl_vmprim_t* vmprim, hcl_errnum_t* errnum) | ||||||
| { | { | ||||||
| 	hcl_t* hcl; | 	hcl_t* hcl; | ||||||
|  |  | ||||||
| @ -37,7 +37,7 @@ hcl_t* hcl_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_oow_t heapsize, const | |||||||
| 	hcl = (hcl_t*)HCL_MMGR_ALLOC(mmgr, HCL_SIZEOF(*hcl) + xtnsize); | 	hcl = (hcl_t*)HCL_MMGR_ALLOC(mmgr, HCL_SIZEOF(*hcl) + xtnsize); | ||||||
| 	if (hcl) | 	if (hcl) | ||||||
| 	{ | 	{ | ||||||
| 		if (hcl_init(hcl, mmgr, heapsize, vmprim) <= -1) | 		if (hcl_init(hcl, mmgr, vmprim) <= -1) | ||||||
| 		{ | 		{ | ||||||
| 			if (errnum) *errnum = hcl->errnum; | 			if (errnum) *errnum = hcl->errnum; | ||||||
| 			HCL_MMGR_FREE (mmgr, hcl); | 			HCL_MMGR_FREE (mmgr, hcl); | ||||||
| @ -93,7 +93,7 @@ static void free_heap (hcl_t* hcl, void* ptr) | |||||||
| 	hcl_freemem (hcl, ptr); | 	hcl_freemem (hcl, ptr); | ||||||
| } | } | ||||||
|  |  | ||||||
| int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, hcl_oow_t heapsz, const hcl_vmprim_t* vmprim) | int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, const hcl_vmprim_t* vmprim) | ||||||
| { | { | ||||||
| 	int modtab_inited = 0; | 	int modtab_inited = 0; | ||||||
| 	int n; | 	int n; | ||||||
| @ -157,9 +157,6 @@ int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, hcl_oow_t heapsz, const hcl_vmprim_t | |||||||
| 	hcl->proc_map_free_first = -1; | 	hcl->proc_map_free_first = -1; | ||||||
| 	hcl->proc_map_free_last = -1; | 	hcl->proc_map_free_last = -1; | ||||||
|  |  | ||||||
| 	/* remember the requested heap size. but push back the actuall heap creation to hcl_ignite() */ |  | ||||||
| 	hcl->_reqheapsz = heapsz; |  | ||||||
|  |  | ||||||
| 	if (hcl->vmprim.dl_startup) hcl->vmprim.dl_startup (hcl); | 	if (hcl->vmprim.dl_startup) hcl->vmprim.dl_startup (hcl); | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
|  | |||||||
| @ -1392,7 +1392,6 @@ struct hcl_t | |||||||
| 	} log; | 	} log; | ||||||
| 	/* ========================= */ | 	/* ========================= */ | ||||||
|  |  | ||||||
| 	hcl_oow_t _reqheapsz; |  | ||||||
| 	hcl_heap_t* heap; | 	hcl_heap_t* heap; | ||||||
|  |  | ||||||
| 	/* ========================= */ | 	/* ========================= */ | ||||||
| @ -1742,7 +1741,6 @@ extern "C" { | |||||||
| HCL_EXPORT hcl_t* hcl_open ( | HCL_EXPORT hcl_t* hcl_open ( | ||||||
| 	hcl_mmgr_t*         mmgr, | 	hcl_mmgr_t*         mmgr, | ||||||
| 	hcl_oow_t           xtnsize, | 	hcl_oow_t           xtnsize, | ||||||
| 	hcl_oow_t           heapsize, |  | ||||||
| 	const hcl_vmprim_t* vmprim, | 	const hcl_vmprim_t* vmprim, | ||||||
| 	hcl_errnum_t*       errnum | 	hcl_errnum_t*       errnum | ||||||
| ); | ); | ||||||
| @ -1750,13 +1748,11 @@ HCL_EXPORT hcl_t* hcl_open ( | |||||||
| HCL_EXPORT hcl_t* hcl_openstdwithmmgr ( | HCL_EXPORT hcl_t* hcl_openstdwithmmgr ( | ||||||
| 	hcl_mmgr_t*         mmgr, | 	hcl_mmgr_t*         mmgr, | ||||||
| 	hcl_oow_t           xtnsize, | 	hcl_oow_t           xtnsize, | ||||||
| 	hcl_oow_t           heapsize, |  | ||||||
| 	hcl_errnum_t*       errnum | 	hcl_errnum_t*       errnum | ||||||
| ); | ); | ||||||
|  |  | ||||||
| HCL_EXPORT hcl_t* hcl_openstd ( | HCL_EXPORT hcl_t* hcl_openstd ( | ||||||
| 	hcl_oow_t           xtnsize, | 	hcl_oow_t           xtnsize, | ||||||
| 	hcl_oow_t           heapsize, |  | ||||||
| 	hcl_errnum_t*       errnum | 	hcl_errnum_t*       errnum | ||||||
| ); | ); | ||||||
|  |  | ||||||
| @ -1767,7 +1763,6 @@ HCL_EXPORT void hcl_close ( | |||||||
| HCL_EXPORT int hcl_init ( | HCL_EXPORT int hcl_init ( | ||||||
| 	hcl_t*              hcl, | 	hcl_t*              hcl, | ||||||
| 	hcl_mmgr_t*         mmgr, | 	hcl_mmgr_t*         mmgr, | ||||||
| 	hcl_oow_t           heapsize, |  | ||||||
| 	const hcl_vmprim_t* vmprim | 	const hcl_vmprim_t* vmprim | ||||||
| ); | ); | ||||||
|  |  | ||||||
| @ -1943,7 +1938,8 @@ HCL_EXPORT hcl_oop_t hcl_shallowcopy ( | |||||||
|  * The hcl_ignite() function creates key initial objects. |  * The hcl_ignite() function creates key initial objects. | ||||||
|  */ |  */ | ||||||
| HCL_EXPORT int hcl_ignite ( | HCL_EXPORT int hcl_ignite ( | ||||||
| 	hcl_t* hcl | 	hcl_t*      hcl, | ||||||
|  | 	hcl_oow_t   heapsize | ||||||
| ); | ); | ||||||
|  |  | ||||||
| HCL_EXPORT int hcl_addbuiltinprims ( | HCL_EXPORT int hcl_addbuiltinprims ( | ||||||
|  | |||||||
| @ -885,7 +885,7 @@ hcl_json_t* hcl_json_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_json_prim_t* | |||||||
| 		return HCL_NULL; | 		return HCL_NULL; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	hcl = hcl_openstdwithmmgr(mmgr, HCL_SIZEOF(*xtn), 2048, errnum); | 	hcl = hcl_openstdwithmmgr(mmgr, HCL_SIZEOF(*xtn), errnum); | ||||||
| 	if (!hcl)  | 	if (!hcl)  | ||||||
| 	{ | 	{ | ||||||
| 		HCL_MMGR_FREE (mmgr, json); | 		HCL_MMGR_FREE (mmgr, json); | ||||||
|  | |||||||
| @ -2922,7 +2922,7 @@ static void cb_vm_cleanup (hcl_t* hcl) | |||||||
|  * STANDARD HCL |  * STANDARD HCL | ||||||
|  * ----------------------------------------------------------------- */ |  * ----------------------------------------------------------------- */ | ||||||
|  |  | ||||||
| hcl_t* hcl_openstdwithmmgr (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_oow_t heapsize, hcl_errnum_t* errnum) | hcl_t* hcl_openstdwithmmgr (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_errnum_t* errnum) | ||||||
| { | { | ||||||
| 	hcl_t* hcl; | 	hcl_t* hcl; | ||||||
| 	hcl_vmprim_t vmprim; | 	hcl_vmprim_t vmprim; | ||||||
| @ -2946,7 +2946,7 @@ hcl_t* hcl_openstdwithmmgr (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_oow_t heaps | |||||||
| 	vmprim.vm_muxwait = vm_muxwait; | 	vmprim.vm_muxwait = vm_muxwait; | ||||||
| 	vmprim.vm_sleep = vm_sleep; | 	vmprim.vm_sleep = vm_sleep; | ||||||
|  |  | ||||||
| 	hcl = hcl_open(mmgr, HCL_SIZEOF(xtn_t) + xtnsize, heapsize, &vmprim, errnum); | 	hcl = hcl_open(mmgr, HCL_SIZEOF(xtn_t) + xtnsize, &vmprim, errnum); | ||||||
| 	if (HCL_UNLIKELY(!hcl)) return HCL_NULL; | 	if (HCL_UNLIKELY(!hcl)) return HCL_NULL; | ||||||
|  |  | ||||||
| 	/* adjust the object size by the sizeof xtn_t so that moo_getxtn() returns the right pointer. */ | 	/* adjust the object size by the sizeof xtn_t so that moo_getxtn() returns the right pointer. */ | ||||||
| @ -2969,7 +2969,7 @@ hcl_t* hcl_openstdwithmmgr (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_oow_t heaps | |||||||
| 	return hcl; | 	return hcl; | ||||||
| } | } | ||||||
|  |  | ||||||
| hcl_t* hcl_openstd (hcl_oow_t xtnsize, hcl_oow_t heapsize, hcl_errnum_t* errnum) | hcl_t* hcl_openstd (hcl_oow_t xtnsize, hcl_errnum_t* errnum) | ||||||
| { | { | ||||||
| 	return hcl_openstdwithmmgr(&sys_mmgr, xtnsize, heapsize, errnum); | 	return hcl_openstdwithmmgr(&sys_mmgr, xtnsize, errnum); | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user