Mercurial > hg > xmms-sid
comparison src/xs_length.c @ 241:291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 21 Dec 2004 15:05:03 +0000 |
parents | 608f31f6c095 |
children | cab5ec6127ee |
comparison
equal
deleted
inserted
replaced
240:f436e16fa6d9 | 241:291715a519e2 |
---|---|
114 /* Read database to memory | 114 /* Read database to memory |
115 */ | 115 */ |
116 gint xs_sldb_read(t_xs_sldb *db, gchar *dbFilename) | 116 gint xs_sldb_read(t_xs_sldb *db, gchar *dbFilename) |
117 { | 117 { |
118 FILE *inFile; | 118 FILE *inFile; |
119 gchar inLine[XS_BUFSIZE]; | 119 gchar inLine[XS_BUF_SIZE]; |
120 guint lineNum, linePos; | 120 guint lineNum, linePos; |
121 gboolean iOK; | 121 gboolean iOK; |
122 t_xs_sldb_node *tmpNode; | 122 t_xs_sldb_node *tmpNode; |
123 assert(db); | 123 assert(db); |
124 | 124 |
132 /* Read and parse the data */ | 132 /* Read and parse the data */ |
133 lineNum = 0; | 133 lineNum = 0; |
134 | 134 |
135 while (!feof(inFile)) | 135 while (!feof(inFile)) |
136 { | 136 { |
137 fgets(inLine, sizeof(inLine), inFile); | 137 fgets(inLine, XS_BUF_SIZE, inFile); |
138 inLine[XS_BUF_SIZE-1] = 0; | |
138 lineNum++; | 139 lineNum++; |
139 | 140 |
140 /* Check if it is datafield */ | 141 /* Check if it is datafield */ |
141 if (isxdigit(inLine[0])) | 142 if (isxdigit(inLine[0])) |
142 { | 143 { |
422 { | 423 { |
423 FILE *inFile; | 424 FILE *inFile; |
424 t_xs_md5state inState; | 425 t_xs_md5state inState; |
425 t_xs_psidv1_header psidH; | 426 t_xs_psidv1_header psidH; |
426 t_xs_psidv2_header psidH2; | 427 t_xs_psidv2_header psidH2; |
427 #ifdef XS_SIDBUF_DYNAMIC | 428 #ifdef XS_BUF_DYNAMIC |
428 guint8 *songData; | 429 guint8 *songData; |
429 #else | 430 #else |
430 guint8 songData[XS_SIDBUF_SIZE]; | 431 guint8 songData[XS_SIDBUF_SIZE]; |
431 #endif | 432 #endif |
432 guint8 ib8[2], i8; | 433 guint8 ib8[2], i8; |
466 psidH2.startPage = fgetc(inFile); | 467 psidH2.startPage = fgetc(inFile); |
467 psidH2.pageLength = fgetc(inFile); | 468 psidH2.pageLength = fgetc(inFile); |
468 psidH2.reserved = xs_rd_be16(inFile); | 469 psidH2.reserved = xs_rd_be16(inFile); |
469 } | 470 } |
470 | 471 |
471 #ifdef XS_SIDBUF_DYNAMIC | 472 #ifdef XS_BUF_DYNAMIC |
472 /* Allocate buffer */ | 473 /* Allocate buffer */ |
473 songData = (guint8 *) g_malloc(XS_SIDBUF_SIZE * sizeof(guint8)); | 474 songData = (guint8 *) g_malloc(XS_SIDBUF_SIZE * sizeof(guint8)); |
474 if (!songData) | 475 if (!songData) |
475 { | 476 { |
476 fclose(inFile); | 477 fclose(inFile); |
492 /* Append "as is" */ | 493 /* Append "as is" */ |
493 xs_md5_append(&inState, songData, iRes); | 494 xs_md5_append(&inState, songData, iRes); |
494 } | 495 } |
495 | 496 |
496 | 497 |
497 #ifdef XS_SIDBUF_DYNAMIC | 498 #ifdef XS_BUF_DYNAMIC |
498 /* Free buffer */ | 499 /* Free buffer */ |
499 g_free(songData); | 500 g_free(songData); |
500 #endif | 501 #endif |
501 | 502 |
502 /* Append header data to hash */ | 503 /* Append header data to hash */ |