Minor changes.

This commit is contained in:
Vreixo Formoso 2007-12-23 15:39:41 +01:00
parent 002a832ac3
commit b8aa48038b
4 changed files with 24 additions and 5 deletions

View File

@ -92,6 +92,14 @@ int iso_ring_buffer_new(IsoRingBuffer **rbuf)
return ISO_SUCCESS; return ISO_SUCCESS;
} }
void iso_ring_buffer_free(IsoRingBuffer *buf)
{
pthread_mutex_destroy(&buf->mutex);
pthread_cond_destroy(&buf->empty);
pthread_cond_destroy(&buf->full);
free(buf);
}
/** /**
* Write count bytes into buffer. It blocks until all bytes where written or * Write count bytes into buffer. It blocks until all bytes where written or
* reader close the buffer. * reader close the buffer.

View File

@ -21,13 +21,18 @@ typedef struct iso_ring_buffer IsoRingBuffer;
/** /**
* Create a new buffer. * Create a new buffer.
* *
* The created buffer can be freed with free(3) * The created buffer can be freed with iso_ring_buffer_free(3)
* *
* @return * @return
* 1 success, < 0 error * 1 success, < 0 error
*/ */
int iso_ring_buffer_new(IsoRingBuffer **rbuf); int iso_ring_buffer_new(IsoRingBuffer **rbuf);
/**
* Free a given buffer
*/
void iso_ring_buffer_free(IsoRingBuffer *buf);
/** /**
* Write count bytes into buffer. It blocks until all bytes where written or * Write count bytes into buffer. It blocks until all bytes where written or
* reader close the buffer. * reader close the buffer.

View File

@ -31,6 +31,7 @@ void ecma119_image_free(Ecma119Image *t)
ecma119_node_free(t->root); ecma119_node_free(t->root);
iso_image_unref(t->image); iso_image_unref(t->image);
iso_rbtree_destroy(t->files, iso_file_src_free); iso_rbtree_destroy(t->files, iso_file_src_free);
iso_ring_buffer_free(t->buffer);
for (i = 0; i < t->nwriters; ++i) { for (i = 0; i < t->nwriters; ++i) {
IsoImageWriter *writer = t->writers[i]; IsoImageWriter *writer = t->writers[i];
@ -39,7 +40,6 @@ void ecma119_image_free(Ecma119Image *t)
} }
free(t->input_charset); free(t->input_charset);
free(t->writers); free(t->writers);
free(t->buffer);
free(t); free(t);
} }

View File

@ -320,7 +320,8 @@ int contains_name(Ecma119Node *dir, const char *name)
* but never under 3 characters. * but never under 3 characters.
*/ */
static static
int mangle_dir(Ecma119Node *dir, int max_file_len, int max_dir_len) int mangle_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
int max_dir_len)
{ {
int i, nchildren; int i, nchildren;
Ecma119Node **children; Ecma119Node **children;
@ -449,6 +450,8 @@ int mangle_dir(Ecma119Node *dir, int max_file_len, int max_dir_len)
if (new == NULL) { if (new == NULL) {
return ISO_MEM_ERROR; return ISO_MEM_ERROR;
} }
iso_msg_debug(img->image, "\"%s\" renamed to \"%s\"",
children[k]->iso_name, new);
free(children[k]->iso_name); free(children[k]->iso_name);
children[k]->iso_name = new; children[k]->iso_name = new;
/* /*
@ -484,7 +487,7 @@ int mangle_dir(Ecma119Node *dir, int max_file_len, int max_dir_len)
for (i = 0; i < nchildren; ++i) { for (i = 0; i < nchildren; ++i) {
int ret; int ret;
if (children[i]->type == ECMA119_DIR) { if (children[i]->type == ECMA119_DIR) {
ret = mangle_dir(children[i], max_file_len, max_dir_len); ret = mangle_dir(img, children[i], max_file_len, max_dir_len);
if (ret < 0) { if (ret < 0) {
/* error */ /* error */
return ret; return ret;
@ -507,7 +510,7 @@ int mangle_tree(Ecma119Image *img)
} else { } else {
max_file = max_dir = 31; max_file = max_dir = 31;
} }
return mangle_dir(img->root, max_file, max_dir); return mangle_dir(img, img->root, max_file, max_dir);
} }
@ -525,8 +528,11 @@ int ecma119_tree_create(Ecma119Image *img)
return ret; return ret;
} }
img->root = root; img->root = root;
iso_msg_debug(img->image, "Sorting the low level tree...");
sort_tree(root); sort_tree(root);
iso_msg_debug(img->image, "Mangling names...");
ret = mangle_tree(img); ret = mangle_tree(img);
if (ret < 0) { if (ret < 0) {
return ret; return ret;