예제 #1
0
파일: memory.c 프로젝트: muennich/mupdf
void *
fz_malloc_no_throw(fz_context *ctx, size_t size)
{
	if (size == 0)
		return NULL;

	return do_scavenging_malloc(ctx, size);
}
예제 #2
0
void *
fz_malloc(fz_context *ctx, unsigned int size)
{
	void *p;

	if (size == 0)
		return NULL;

	p = do_scavenging_malloc(ctx, size);
	if (!p)
		fz_throw(ctx, "malloc of %d bytes failed", size);
	return p;
}
예제 #3
0
파일: memory.c 프로젝트: muennich/mupdf
void *
fz_malloc(fz_context *ctx, size_t size)
{
	void *p;

	if (size == 0)
		return NULL;

	p = do_scavenging_malloc(ctx, size);
	if (!p)
		fz_throw(ctx, FZ_ERROR_MEMORY, "malloc of %zu bytes failed", size);
	return p;
}
예제 #4
0
void *
fz_malloc_array_no_throw(fz_context *ctx, unsigned int count, unsigned int size)
{
	if (count == 0 || size == 0)
		return 0;

	if (count > UINT_MAX / size)
	{
		fprintf(stderr, "error: malloc of array (%d x %d bytes) failed (integer overflow)", count, size);
		return NULL;
	}

	return do_scavenging_malloc(ctx, count * size);
}
예제 #5
0
void *
fz_malloc_array(fz_context *ctx, unsigned int count, unsigned int size)
{
	void *p;

	if (count == 0 || size == 0)
		return 0;

	if (count > UINT_MAX / size)
		fz_throw(ctx, "malloc of array (%d x %d bytes) failed (integer overflow)", count, size);

	p = do_scavenging_malloc(ctx, count * size);
	if (!p)
		fz_throw(ctx, "malloc of array (%d x %d bytes) failed", count, size);
	return p;
}
예제 #6
0
파일: memory.c 프로젝트: muennich/mupdf
void *
fz_malloc_array_no_throw(fz_context *ctx, size_t count, size_t size)
{
	if (count == 0 || size == 0)
		return 0;

	if (count > SIZE_MAX / size)
	{
		char buf[100];
		fz_snprintf(buf, sizeof buf, "error: malloc of array (%zu x %zu bytes) failed (size_t overflow)", count, size);
		fprintf(stderr, "%s\n", buf);
		return NULL;
	}

	return do_scavenging_malloc(ctx, count * size);
}
예제 #7
0
파일: memory.c 프로젝트: muennich/mupdf
void *
fz_malloc_array(fz_context *ctx, size_t count, size_t size)
{
	void *p;

	if (count == 0 || size == 0)
		return 0;

	if (count > SIZE_MAX / size)
		fz_throw(ctx, FZ_ERROR_MEMORY, "malloc of array (%zu x %zu bytes) failed (size_t overflow)", count, size);

	p = do_scavenging_malloc(ctx, count * size);
	if (!p)
		fz_throw(ctx, FZ_ERROR_MEMORY, "malloc of array (%zu x %zu bytes) failed", count, size);
	return p;
}
예제 #8
0
void *
fz_calloc(fz_context *ctx, unsigned int count, unsigned int size)
{
	void *p;

	if (count == 0 || size == 0)
		return 0;

	if (count > UINT_MAX / size)
	{
		fz_throw(ctx, "calloc (%d x %d bytes) failed (integer overflow)", count, size);
	}

	p = do_scavenging_malloc(ctx, count * size);
	if (!p)
	{
		fz_throw(ctx, "calloc (%d x %d bytes) failed", count, size);
	}
	memset(p, 0, count*size);
	return p;
}
예제 #9
0
void *
fz_calloc_no_throw(fz_context *ctx, unsigned int count, unsigned int size)
{
	void *p;

	if (count == 0 || size == 0)
		return 0;

	if (count > UINT_MAX / size)
	{
		fprintf(stderr, "error: calloc (%d x %d bytes) failed (integer overflow)\n", count, size);
		return NULL;
	}

	p = do_scavenging_malloc(ctx, count * size);
	if (p)
	{
		memset(p, 0, count*size);
	}
	return p;
}
예제 #10
0
파일: memory.c 프로젝트: muennich/mupdf
void *
fz_calloc(fz_context *ctx, size_t count, size_t size)
{
	void *p;

	if (count == 0 || size == 0)
		return 0;

	if (count > SIZE_MAX / size)
	{
		fz_throw(ctx, FZ_ERROR_MEMORY, "calloc (%zu x %zu bytes) failed (size_t overflow)", count, size);
	}

	p = do_scavenging_malloc(ctx, count * size);
	if (!p)
	{
		fz_throw(ctx, FZ_ERROR_MEMORY, "calloc (%zu x %zu bytes) failed", count, size);
	}
	memset(p, 0, count*size);
	return p;
}
예제 #11
0
void *
fz_malloc_no_throw(fz_context *ctx, unsigned int size)
{
	return do_scavenging_malloc(ctx, size);
}