# HG changeset patch # User John Tsiombikas # Date 1347498638 -10800 # Node ID 66956b1e5e3f7d2de655e780808627d2eb40cdb5 # Parent 7fbed016e73979f35a6d393b649acf66004dc03c added missing psys_create_attr/psys_free_attr and some checking in load_attr diff -r 7fbed016e739 -r 66956b1e5e3f src/pattr.c --- a/src/pattr.c Tue Sep 11 03:26:13 2012 +0300 +++ b/src/pattr.c Thu Sep 13 04:10:38 2012 +0300 @@ -48,6 +48,24 @@ tex_cls = cls; } +struct psys_attributes *psys_create_attr(void) +{ + struct psys_attributes *attr = malloc(sizeof *attr); + if(attr) { + if(psys_init_attr(attr) == -1) { + free(attr); + attr = 0; + } + } + return attr; +} + +void psys_free_attr(struct psys_attributes *attr) +{ + psys_destroy_attr(attr); + free(attr); +} + int psys_init_attr(struct psys_attributes *attr) { memset(attr, 0, sizeof *attr); @@ -143,6 +161,10 @@ FILE *fp; int res; + if(!fname) { + return -1; + } + if(!(fp = fopen(fname, "r"))) { fprintf(stderr, "%s: failed to read file: %s: %s\n", __func__, fname, strerror(errno)); return -1; diff -r 7fbed016e739 -r 66956b1e5e3f src/pattr.h --- a/src/pattr.h Tue Sep 11 03:26:13 2012 +0300 +++ b/src/pattr.h Thu Sep 13 04:10:38 2012 +0300 @@ -36,6 +36,9 @@ void psys_texture_loader(unsigned int (*load)(const char*, void*), void (*unload)(unsigned int, void*), void *cls); +struct psys_attributes *psys_create_attr(void); +void psys_free_attr(struct psys_attributes *attr); + int psys_init_attr(struct psys_attributes *attr); void psys_destroy_attr(struct psys_attributes *attr);