static void test(void) { gc_init(); test_mini_gc_malloc_free(); test_garbage_collect(); test_garbage_collect_load_test(); }
/* create an executable context using the given device, output configuration, and semantics. */ XPAPI Xpost_Context *xpost_create(const char *device, Xpost_Output_Type output_type, const void *outputptr, Xpost_Showpage_Semantics semantics, Xpost_Output_Message output_msg, Xpost_Set_Size set_size, int width, int height) { Xpost_Object sd, ud; int ret; const char *outfile = NULL; const char *bufferin = NULL; char **bufferout = NULL; int quiet; switch (output_msg) { case XPOST_OUTPUT_MESSAGE_QUIET: quiet = 1; _xpost_interpreter_is_tracing = 0; break; case XPOST_OUTPUT_MESSAGE_VERBOSE: quiet = 0; _xpost_interpreter_is_tracing = 0; break; case XPOST_OUTPUT_MESSAGE_TRACING: quiet = 0; _xpost_interpreter_is_tracing = 1; break; default: XPOST_LOG_ERR("Wrong output message value"); return NULL;; } switch (output_type) { case XPOST_OUTPUT_FILENAME: outfile = outputptr; break; case XPOST_OUTPUT_BUFFERIN: bufferin = outputptr; break; case XPOST_OUTPUT_BUFFEROUT: bufferout = (char **)outputptr; break; case XPOST_OUTPUT_DEFAULT: break; } #if 0 test_memory(); if (!test_garbage_collect(xpost_interpreter_cid_init, xpost_interpreter_cid_get_context, xpost_interpreter_get_initializing, xpost_interpreter_set_initializing, xpost_interpreter_alloc_local_memory, xpost_interpreter_alloc_global_memory)) return NULL; #endif nextid = 0; /*reset process counter */ /* Allocate and initialize all interpreter data structures. */ ret = initalldata(device); if (!ret) { return NULL; } /* extract systemdict and userdict for additional definitions */ sd = xpost_stack_bottomup_fetch(xpost_ctx->lo, xpost_ctx->ds, 0); ud = xpost_stack_bottomup_fetch(xpost_ctx->lo, xpost_ctx->ds, 2); setlocalconfig(xpost_ctx, sd, device, outfile, bufferin, bufferout, semantics, set_size, width, height); if (quiet) { xpost_dict_put(xpost_ctx, sd /*xpost_stack_bottomup_fetch(ctx->lo, ctx->ds, 0)*/ , xpost_name_cons(xpost_ctx, "QUIET"), null); } xpost_stack_clear(xpost_ctx->lo, xpost_ctx->hold); xpost_interpreter_set_initializing(0); loadinitps(xpost_ctx); ret = copyudtosd(xpost_ctx, ud, sd); if (ret) { XPOST_LOG_ERR("%s error in copyudtosd", errorname[ret]); return NULL; } /* make systemdict readonly FIXME: use new access semantics */ xpost_dict_put(xpost_ctx, sd, xpost_name_cons(xpost_ctx, "systemdict"), sd); xpost_object_set_access(xpost_ctx, sd, XPOST_OBJECT_TAG_ACCESS_READ_ONLY); #if 0 if (!xpost_stack_bottomup_replace(xpost_ctx->lo, xpost_ctx->ds, 0, xpost_object_set_access(xpost_ctx, sd, XPOST_OBJECT_TAG_ACCESS_READ_ONLY))) { XPOST_LOG_ERR("cannot replace systemdict in dict stack"); return NULL; } #endif xpost_interpreter_set_initializing(0); return xpost_ctx; }