Skip to content

Commit

Permalink
Fix sYSMALLOC assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
matiaslina committed Feb 28, 2014
1 parent 783ce36 commit 18d56f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CC=clang
TARGET=font2png

CFLAGS=-Wall -Werror -Wextra -O0 -g \
CFLAGS=-Wall -Werror -Wextra -O0 -g -ggdb3 \
`pkg-config --cflags pangocairo`
LDFLAGS=`pkg-config --libs pangocairo`

Expand Down
12 changes: 5 additions & 7 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ static void parse_stroke(char *str, Color *c, double *size)

int main(int argc, char *argv[])
{
int opt;
int opt = 0;
char *text = NULL;
char *buffer = calloc(256, sizeof(char));
size_t text_len = 0;
ssize_t count;
ssize_t count = 0;
opterr= 0;
struct options_t options = {
.text = NULL,
Expand Down Expand Up @@ -108,7 +108,7 @@ int main(int argc, char *argv[])
switch(opt)
{
case 'p':
options.fpa = atoi(optarg);
options.fpa = 0;
break;
case 'f':
options.font = optarg;
Expand Down Expand Up @@ -185,14 +185,12 @@ int main(int argc, char *argv[])
/* Get the text from stdin */
while((count = read(STDIN_FILENO, buffer, 256)) > 0)
{
text = realloc(text, text_len + count);
text = realloc(text, text_len + count + 1);
memset(text+text_len, 0, count +1);
text = strncat(text, buffer, count);
text_len += count;
}

text = realloc(text, text_len + 1);
text[text_len] = '\0';

if(count == -1)
{
fprintf(stderr, "Failed to read()");
Expand Down
24 changes: 12 additions & 12 deletions renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

#include "renderer.h"

#define FONT "Traditional Arabic"
#define SHORT_TEXT "Hello world\0"
#define LONG_TEXT "Hello my dear world, how are you? Hope that fine.\0"
#define ARABIC_TEXT "شيء يحشر السوبر المخادع"

#define b2s(x) (x)?"true":"false"
#ifndef MAX
#define MAX(a,b) (a>b)?a:b
#endif
#ifndef MIN
#define MIN(a,b) (a<b)?a:b
#endif

/* Helpers */
#if 0
Expand All @@ -28,8 +28,8 @@ static void increment_layout_size(cairo_t *cr, PangoLayout *layout,
static gboolean wrap_is_well_formed(PangoLayout *layout, const gchar *cmpstr);

/* Private functions */
static int get_font_size(struct options_t options);
static void render_text(cairo_t *cr, int size, struct options_t options);
static gulong get_font_size(struct options_t options);
static void render_text(cairo_t *cr, gulong size, struct options_t options);

/**********************************************/

Expand Down Expand Up @@ -151,11 +151,11 @@ increment_layout_size(cairo_t *cr, PangoLayout *layout,
pango_cairo_update_layout(cr, layout);
}

static int
static gulong
get_font_size(struct options_t options)
{
int result = 1;
int size = 1;
gulong size = 1;
int h = 0, w = 0;
const gchar *last_line_str;
cairo_t *cr = NULL;
Expand Down Expand Up @@ -221,7 +221,7 @@ get_font_size(struct options_t options)
}

static void
render_text(cairo_t *cr, int size, struct options_t options)
render_text(cairo_t *cr, gulong size, struct options_t options)
{
PangoLayout *layout;
PangoFontDescription *description;
Expand Down Expand Up @@ -269,7 +269,7 @@ render_text(cairo_t *cr, int size, struct options_t options)
int
make_png(struct options_t options)
{
int size = 0;
gulong size = 0;
cairo_t *cr = NULL;
cairo_surface_t *surface = NULL;
cairo_status_t status;
Expand Down

0 comments on commit 18d56f9

Please sign in to comment.