Exemple #1
0
/* Create the default allocator, and return it. */
gs_memory_t *
gs_malloc_init(const gs_memory_t *parent)
{
    gs_malloc_memory_t *malloc_memory_default = gs_malloc_memory_init();
    gs_memory_t *memory_t_default;

    if (parent)
	malloc_memory_default->gs_lib_ctx = parent->gs_lib_ctx;
    else 
        gs_lib_ctx_init((gs_memory_t *)malloc_memory_default);

#if defined(USE_RETRY_MEMORY_WRAPPER)
    gs_malloc_wrap(&memory_t_default, malloc_memory_default);
#else
    memory_t_default = (gs_memory_t *)malloc_memory_default;
#endif
    memory_t_default->stable_memory = memory_t_default;
    return memory_t_default;
}
Exemple #2
0
/* Create the default allocator, and return it. */
gs_memory_t *
gs_malloc_init(void)
{
    gs_malloc_memory_t *malloc_memory_default = gs_malloc_memory_init();
    gs_memory_t *memory_t_default;

    if (malloc_memory_default == NULL)
        return NULL;

    if (gs_lib_ctx_init((gs_memory_t *)malloc_memory_default) != 0)
        return NULL;

#if defined(USE_RETRY_MEMORY_WRAPPER)
    gs_malloc_wrap(&memory_t_default, malloc_memory_default);
#else
    memory_t_default = (gs_memory_t *)malloc_memory_default;
#endif
    memory_t_default->stable_memory = memory_t_default;
    return memory_t_default;
}
/* Create a bandlist allocator. */
static int
alloc_bandlist_memory(gs_memory_t ** final_allocator,
                      gs_memory_t * base_allocator)
{
    gs_memory_t *data_allocator = 0;
    gs_memory_locked_t *locked_allocator = 0;
    int code = 0;

#if defined(DEBUG) && defined(DebugBandlistMemorySize)
    code = alloc_render_memory(&data_allocator, base_allocator,
                               DebugBandlistMemorySize);
    if (code < 0)
        return code;
#else
    data_allocator = (gs_memory_t *)gs_malloc_memory_init();
    if (!data_allocator)
        return_error(gs_error_VMerror);
#endif
    locked_allocator = (gs_memory_locked_t *)
        gs_alloc_bytes_immovable(data_allocator, sizeof(gs_memory_locked_t),
                                 "alloc_bandlist_memory(locked allocator)");
    if (!locked_allocator)
        goto alloc_err;
    code = gs_memory_locked_init(locked_allocator, data_allocator);
    if (code < 0)
        goto alloc_err;
    *final_allocator = (gs_memory_t *)locked_allocator;
    return 0;
alloc_err:
    if (locked_allocator)
        free_bandlist_memory((gs_memory_t *)locked_allocator);
    else if (data_allocator)
        gs_memory_free_all(data_allocator, FREE_ALL_EVERYTHING,
                           "alloc_bandlist_memory(data allocator)");
    return (code < 0 ? code : gs_note_error(gs_error_VMerror));
}