Beispiel #1
0
/**
 * Frees a child-map.
 */
void cm_free(
    ChildMap* const     map)            /**< [in] Pointer to the child-map or
                                         *   NULL */
{
    if (NULL != map) {
        while (0 < map->count--) {
            Entry* const    entry = *(Entry**)map->root;

            (void)tdelete(entry, &map->root, compare);
            free(entry->command);
            free(entry);
        }

        strBuf_free(map->buf);
        free(map);
    }
}
Beispiel #2
0
/**
 * Sets an LDM product-identifier from a GRIB message.
 *
 * Not Atomic,
 * Idempotent,
 * Thread-safe
 *
 * @param[out] ident      Product-identifier buffer.
 * @param[in]  identSize  Size of product-identifier buffer in bytes.
 * @param[in]  decoded    Decoded GRIB message.
 * @param[in]  wmoHead    WMO header associated with the GRIB message.
 * @retval     0          Success. \c *ident is set.
 * @retval     1          GRIB message has no data.
 * @retval     3          System error.
 */
static int setIdent(
    char* const            ident,
    const size_t           identSize,
    DecodedGrib2Msg* const decoded,
    const char* const      wmoHead)
{
    const size_t   numFields = g2d_getNumFields(decoded);
    int            status;

    if (0 == numFields) {
        log_add("GRIB message has no fields");
        status = 1;
    }
    else {
        StringBuf* const prods = strBuf_new(127); /* initially empty */

        if (NULL == prods) {
            log_add_syserr("Couldn't allocate string-buffer for products");
            log_flush_error();
            status = 3;
        }
        else {
            Gribmsg          gribMsg;
            Geminfo          gemInfo;
            int              modelId;

            status = appendParameterNames(prods, decoded, &gribMsg, &gemInfo);

            if (0 == status) {
                status = getModelId(decoded, &modelId);

                if (0 == status)
                    composeIdent(ident, identSize, decoded, &gribMsg, &gemInfo,
                            prods, wmoHead, modelId);
            }

            strBuf_free(prods);
        } /* "prods" allocated */
    } /* numFields > 0 */

    return status;
}
Beispiel #3
0
/*
 * Frees the resources allocated to an upstream filter.
 *
 * Arguments:
 *      upFilter        Pointer to the upsteam filter to have its resources 
 *                      freed.
 */
void
upFilter_free(
    UpFilter* const     upFilter)
{
    if (NULL != upFilter) {
        Element*        elt;
        Element*        next;

        for (elt = upFilter->head; elt != NULL; elt = next) {
            next  = elt->next;

            pat_free(elt->okPattern);

            if (elt->notPattern) {
                pat_free(elt->notPattern);
            }

            free(elt);
        }

        strBuf_free(upFilter->strBuf);
        free(upFilter);
    }
}