Changeset 957


Ignore:
Timestamp:
Feb 6, 2020, 3:12:42 PM (5 years ago)
Author:
knut
Message:

Added function for allocating memory for map values (allocateMapValue). Fixed issue with getting attributes from input data node. Added code to support MIME subtype attributes in key-value pairs.

Location:
trunk/zoo-project/zoo-kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/request_parser.c

    r946 r957  
    416416      while (pToken != NULL)
    417417        {
    418           outputs_as_text[i] =
     418/*        outputs_as_text[i] =
    419419            (char *) malloc ((strlen (pToken) + 1) * sizeof (char));
    420420          if (outputs_as_text[i] == NULL)
     
    427427                    pToken);
    428428          pToken = strtok (NULL, ";");
    429           i++;
     429          i++; */
     430         
     431          // knut : rewrite above fragment to enable parsing of mimetype;subtype strings in key-value pairs:
     432         
     433          char* _token = zStrdup(pToken);
     434          pToken = strtok (NULL, ";");
     435         
     436          if (pToken != NULL && strncmp(pToken, "subtype=", 8) == 0)
     437          {
     438                 size_t _length = strlen(pToken) + strlen(_token) + 2;
     439                 outputs_as_text[i] = (char *) malloc(_length * sizeof (char));
     440                 snprintf(outputs_as_text[i], _length, "%s;%s", _token, pToken);
     441                 pToken = strtok (NULL, ";");
     442          }
     443          else
     444          {
     445                 outputs_as_text[i] = (char *) malloc((strlen(_token) + 1) * sizeof (char));
     446                 snprintf (outputs_as_text[i], strlen(_token) + 1, "%s", _token);               
     447          }
     448          free(_token);
     449          i++;   
    430450        }
    431451      for (j = 0; j < i; j++)
     
    862882                    for (l = 0; l < 3; l++){
    863883                      xmlChar *val =
    864                           xmlGetProp (cur4, BAD_CAST coms[l]);
     884                          //xmlGetProp (cur4, BAD_CAST coms[l]);
     885                          xmlGetProp (cur2, BAD_CAST coms[l]);   // knut : get attributes from the Data xml element, not it's children (the content)
    865886                        if (val != NULL && strlen ((char *) val) > 0){
    866887                          if (tmpmaps->content != NULL)
  • trunk/zoo-project/zoo-kernel/service.c

    r955 r957  
    18291829#endif
    18301830#endif
     1831
     1832/*
     1833 * Dynamically allocate memory for a map value
     1834 *
     1835 * @param node the map for which the value buffer should be allocated
     1836 * @param num_bytes the number of bytes to allocate
     1837 * @return pointer to the allocated memory buffer
     1838 *
     1839 * This function will free, and hence delete, any existing value in the map.
     1840 * The memory should be deallocated by calling freeMap.
     1841 */
     1842char* allocateMapValue(map* node, size_t num_bytes)
     1843{
     1844        if (node == NULL) {
     1845                return NULL;
     1846        }
     1847
     1848        if (node->value != NULL) {
     1849                free(node->value);
     1850        }
     1851        node->value = (char*) malloc(num_bytes);
     1852               
     1853        return node->value;
     1854}
  • trunk/zoo-project/zoo-kernel/service.h

    r949 r957  
    481481  #define zooLogMsg(file,message) logMessage(__FILE__, __func__, __LINE__, (file), (message))
    482482  #define zooLog logMessage(__FILE__, __func__, __LINE__) 
    483 
     483 
     484  // knut : function for pre-allocated memory for a map value;
     485  // processing algorithms may be able to write directly to this space, thereby avoiding unneccesary copying of data
     486  ZOO_DLL_EXPORT char* allocateMapValue(map* node, size_t num_bytes); 
     487 
    484488#ifdef __cplusplus
    485489}
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png