comparison tools/packed.c @ 2489:c64806412be0

Cleanup.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 28 Apr 2020 18:11:59 +0300
parents c7a0913e1032
children 9807ae37ad69
comparison
equal deleted inserted replaced
2488:87c8be2bc8ba 2489:c64806412be0
258 258
259 return DMERR_OK; 259 return DMERR_OK;
260 } 260 }
261 261
262 262
263 int dmPackCreate(const char *filename, DMPackFile ** pack) 263 int dmPackCreate(const char *filename, DMPackFile ** ppack)
264 { 264 {
265 // Allocate packfile-structure 265 DMPackFile *pack;
266 if ((*pack = (DMPackFile *) dmMalloc0(sizeof(DMPackFile))) == NULL) 266
267 if ((pack = *ppack = (DMPackFile *) dmMalloc0(sizeof(DMPackFile))) == NULL)
267 return DMERR_MALLOC; 268 return DMERR_MALLOC;
268 269
269 // Open the file 270 if ((pack->file = fopen(filename, "wb")) == NULL)
270 (*pack)->file = fopen(filename, "wb"); 271 {
271 if ((*pack)->file == NULL) 272 dmFree(pack);
272 {
273 dmFree(*pack);
274 return DMERR_FOPEN; 273 return DMERR_FOPEN;
275 } 274 }
276 275
277 (*pack)->filename = dm_strdup(filename); 276 pack->filename = dm_strdup(filename);
278 277
279 // Set the result
280 return DMERR_OK; 278 return DMERR_OK;
281 } 279 }
282 280
283 281
284 int dmPackAddFile(DMPackFile * pack, const char *filename, 282 int dmPackAddFile(DMPackFile * pack, const char *filename,