mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Fixed wrong use of _alloca which causes crashes on Windows
This commit is contained in:
parent
93fa54a784
commit
b948d9928c
@ -81,11 +81,7 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
int upceanflag = 0;
|
int upceanflag = 0;
|
||||||
|
|
||||||
// Allocate memory for the rendered version
|
// Allocate memory for the rendered version
|
||||||
#ifndef _MSC_VER
|
render = symbol->rendered = (struct zint_render *) malloc(sizeof(struct zint_render));
|
||||||
render = symbol->rendered = malloc(sizeof(struct zint_render));
|
|
||||||
#else
|
|
||||||
render = symbol->rendered = (struct zint_render *)_alloca(sizeof(struct zint_render));
|
|
||||||
#endif
|
|
||||||
render->lines = NULL;
|
render->lines = NULL;
|
||||||
render->strings = NULL;
|
render->strings = NULL;
|
||||||
render->rings = NULL;
|
render->rings = NULL;
|
||||||
@ -566,7 +562,7 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
||||||
textpart[0] = symbol->text[11];
|
textpart[0] = symbol->text[11];
|
||||||
textpart[1] = '\0';
|
textpart[1] = '\0';
|
||||||
textpos = 100;
|
textpos = 100;
|
||||||
textwidth = 6.2;
|
textwidth = 6.2;
|
||||||
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn + (2.0 * scaler), 8.0 * scaler, textwidth * scaler, &last_string);
|
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn + (2.0 * scaler), 8.0 * scaler, textwidth * scaler, &last_string);
|
||||||
textdone = 1;
|
textdone = 1;
|
||||||
@ -686,11 +682,7 @@ struct zint_render_line *render_plot_create_line(float x, float y, float width,
|
|||||||
{
|
{
|
||||||
struct zint_render_line *line;
|
struct zint_render_line *line;
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
line = (struct zint_render_line*) malloc(sizeof(struct zint_render_line));
|
||||||
line = malloc(sizeof(struct zint_render_line));
|
|
||||||
#else
|
|
||||||
line = (struct zint_render_line *)_alloca(sizeof(struct zint_render_line));
|
|
||||||
#endif
|
|
||||||
line->next = NULL;
|
line->next = NULL;
|
||||||
line->x = x;
|
line->x = x;
|
||||||
line->y = y;
|
line->y = y;
|
||||||
@ -719,11 +711,7 @@ struct zint_render_ring *render_plot_create_ring(float x, float y, float radius,
|
|||||||
{
|
{
|
||||||
struct zint_render_ring *ring;
|
struct zint_render_ring *ring;
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
ring = (struct zint_render_ring *) malloc(sizeof(struct zint_render_ring));
|
||||||
ring = malloc(sizeof(struct zint_render_ring));
|
|
||||||
#else
|
|
||||||
ring = (struct zint_render_ring *)_alloca(sizeof(struct zint_render_ring));
|
|
||||||
#endif
|
|
||||||
ring->next = NULL;
|
ring->next = NULL;
|
||||||
ring->x = x;
|
ring->x = x;
|
||||||
ring->y = y;
|
ring->y = y;
|
||||||
@ -748,11 +736,7 @@ struct zint_render_hexagon *render_plot_create_hexagon(float x, float y)
|
|||||||
{
|
{
|
||||||
struct zint_render_hexagon *hexagon;
|
struct zint_render_hexagon *hexagon;
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
hexagon = (struct zint_render_hexagon*) malloc(sizeof(struct zint_render_hexagon));
|
||||||
hexagon = malloc(sizeof(struct zint_render_hexagon));
|
|
||||||
#else
|
|
||||||
hexagon = (struct zint_render_hexagon *)_alloca(sizeof(struct zint_render_hexagon));
|
|
||||||
#endif
|
|
||||||
hexagon->next = NULL;
|
hexagon->next = NULL;
|
||||||
hexagon->x = x;
|
hexagon->x = x;
|
||||||
hexagon->y = y;
|
hexagon->y = y;
|
||||||
@ -781,22 +765,14 @@ int render_plot_add_string(struct zint_symbol *symbol,
|
|||||||
{
|
{
|
||||||
struct zint_render_string *string;
|
struct zint_render_string *string;
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
string = (struct zint_render_string*) malloc(sizeof(struct zint_render_string));
|
||||||
string = malloc(sizeof(struct zint_render_string));
|
|
||||||
#else
|
|
||||||
string = (struct zint_render_string *)_alloca(sizeof(struct zint_render_string));
|
|
||||||
#endif
|
|
||||||
string->next = NULL;
|
string->next = NULL;
|
||||||
string->x = x;
|
string->x = x;
|
||||||
string->y = y;
|
string->y = y;
|
||||||
string->width = width;
|
string->width = width;
|
||||||
string->fsize = fsize;
|
string->fsize = fsize;
|
||||||
string->length = ustrlen(text);
|
string->length = ustrlen(text);
|
||||||
#ifndef _MSC_VER
|
string->text = (unsigned char*) malloc(sizeof(unsigned char) * (ustrlen(text) + 1));
|
||||||
string->text = malloc(sizeof(unsigned char) * (ustrlen(text) + 1));
|
|
||||||
#else
|
|
||||||
string->text = (unsigned char *)_alloca((ustrlen(text) + 1) * sizeof(unsigned char));
|
|
||||||
#endif
|
|
||||||
ustrcpy(string->text, text);
|
ustrcpy(string->text, text);
|
||||||
|
|
||||||
if (*last_string)
|
if (*last_string)
|
||||||
|
Loading…
Reference in New Issue
Block a user