Re: [xml] timsort.h error handling



Here is a patch that propagates the error outside of timsort to xmlXPathNodeSetSort. But question is what to 
do there. So far sorting was not supposed to fail. Timsort needs to allocate extra memory (does not work in 
place) and it can fail. Libxml error can be reported in xmlXPathNodeSetSort, but there is no easy way to 
propagate the error outside xmlXPathNodeSetSort.

Vojtech

-----Original Message-----
From: xml-bounces gnome org [mailto:xml-bounces gnome org] On Behalf Of Ralf Junker
Sent: 1. října 2012 17:23
To: xml gnome org
Subject: [xml] timsort.h error handling

On memory reallocation error, timsort.h just prints to stderr and exits (see code extract below). Should it 
not better propagate the error to the libxml2 error handler?

Ralf

static void TIM_SORT_RESIZE(TEMP_STORAGE_T *store, const size_t new_size) {
  if (store->alloc < new_size)
  {
    SORT_TYPE *tempstore = (SORT_TYPE *)realloc(store->storage, new_size * sizeof(SORT_TYPE));
    if (tempstore == NULL)
    {
      fprintf(stderr, "Error allocating temporary storage for tim sort: need %lu bytes", sizeof(SORT_TYPE) * 
new_size);
      exit(1);
    }
    store->storage = tempstore;
    store->alloc = new_size;
  }
}
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/ xml gnome org https://mail.gnome.org/mailman/listinfo/xml

Attachment: timsort_propagate_error.patch
Description: timsort_propagate_error.patch



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]