Thomas Buck преди 10 години
родител
ревизия
7df7a7fd08
променени са 2 файла, в които са добавени 13 реда и са изтрити 8 реда
  1. 8
    1
      include/utils/pcx.h
  2. 5
    7
      src/utils/pcx.cpp

+ 8
- 1
include/utils/pcx.h Целия файл

11
 #ifndef _UTILS_PCX_H_
11
 #ifndef _UTILS_PCX_H_
12
 #define _UTILS_PCX_H_
12
 #define _UTILS_PCX_H_
13
 
13
 
14
-// Returns 0 on success
14
+/*!
15
+ * \brief Load a PCX image file into a RGBA buffer
16
+ * \param filename path of file to read
17
+ * \param image place where allocated buffer of size (width * height * 4) will be allocated
18
+ * \param width place where image width will be stored
19
+ * \param height place where image height will be stored
20
+ * \returns 0 on success
21
+ */
15
 int pcxLoad(const char *filename, unsigned char **image, unsigned int *width, unsigned int *height);
22
 int pcxLoad(const char *filename, unsigned char **image, unsigned int *width, unsigned int *height);
16
 
23
 
17
 #endif
24
 #endif

+ 5
- 7
src/utils/pcx.cpp Целия файл

154
                 } else {
154
                 } else {
155
                     pcxPrint("Unsupported number of planes (%d)", nPlanes);
155
                     pcxPrint("Unsupported number of planes (%d)", nPlanes);
156
                     delete [] buffer;
156
                     delete [] buffer;
157
+                    delete [] palette;
157
                     delete [] *image;
158
                     delete [] *image;
158
-                    if (palette != NULL)
159
-                        delete [] palette;
159
+                    *image = NULL;
160
                     return -10;
160
                     return -10;
161
                 }
161
                 }
162
             } else {
162
             } else {
171
                 } else {
171
                 } else {
172
                     pcxPrint("Unsupported number of planes (%d)", nPlanes);
172
                     pcxPrint("Unsupported number of planes (%d)", nPlanes);
173
                     delete [] buffer;
173
                     delete [] buffer;
174
+                    delete [] palette;
174
                     delete [] *image;
175
                     delete [] *image;
175
-                    if (palette != NULL)
176
-                        delete [] palette;
176
+                    *image = NULL;
177
                     return -11;
177
                     return -11;
178
                 }
178
                 }
179
             }
179
             }
186
     }
186
     }
187
 
187
 
188
     delete [] buffer;
188
     delete [] buffer;
189
-
190
-    if (palette != NULL)
191
-        delete [] palette;
189
+    delete [] palette;
192
 
190
 
193
     return 0;
191
     return 0;
194
 }
192
 }

Loading…
Отказ
Запис