#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
#include <cairo.h>
#include <SDL.h>
#include <SDL_image.h>
TTF_Font *font;
SDL_Rect *points;
+char **names;
int psize;
int stop = 0;
char *buffer;
char *next;
size_t len;
+ ssize_t r;
int i;
file = fopen (filename, "r");
fscanf (file, "%d\n", &psize);
points = malloc (sizeof (SDL_Rect) * psize);
- if (points == NULL)
+ names = malloc (sizeof (char *) * psize);
+ if (points == NULL || names == NULL)
abort ();
buffer = NULL;
len = 0;
for (i = 0; i < psize; i++)
{
- getline (&buffer, &len, file);
+ r = getline (&buffer, &len, file);
+ buffer[r - 1] = '\0';
points[i].x = strtol (buffer, &next, 0);
- points[i].y = strtol (next+1, NULL, 0);
+ points[i].y = strtol (next+1, &next, 0);
+ strtol (next, &next, 0);
+ while (isspace (*next)) next++;
+ names[i] = strdup (next);
}
fclose (file);
}
SDL_Surface *image;
SDL_Surface *slice;
SDL_Event event;
+ int i;
ReadPoints ("pro-gnu");
SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER);
TTF_Init ();
TTF_Quit ();
SDL_Quit ();
free (points);
+ for (i = 0; i < psize; i++)
+ free (names[i]);
+ free (names);
return 0;
}