Chapter 10
Returning Multiple Values Using Inline::C
Rounding out the set of XSUBs redone as inlined functions, Listing 10 4 contains 
an Inline::C version of the type_data() function from Chapter 9.
Listing 10 4. Inline Function Using Multivalue Return
void type_data(gchar *type) {
  Inline_Stack_Vars;
  GList *keys, *iter;
  HV *hv;
  SV *value;
  char *key;         
  // initialize hash
  hv = newHV();
  // get GList of keys for this type
  keys = gnome_mime_get_keys(type);
  // iterate through keys
  for (iter = keys; iter; iter = iter >next) {
    // get the key from the iterator
    key = iter >data;
   
    // create a new SV and load it with the value for this key
    value = newSVpv(gnome_mime_get_value(type, key), 0);
   
    // store the key/value pair in
    hv_store(hv, key, strlen(key), value, 0);
  }
  // free keys GList
  g_list_free(keys);
  // test context with GIMME_V
  if (GIMME_V == G_ARRAY) {
    // list context   return a list of key/value pairs
    int count = hv_iterinit(hv);
    int i;
    I32 len;
    // get ready for Inline_Stack_Push
    Inline_Stack_Reset;
   
248






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

web hosting perl

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved