1. drmaa2_dict_set(3)
  2. DRMAA2
  3. drmaa2_dict_set(3)

NAME

drmaa2_dict_set - drmaa2_dict_set, Adds / changes a key value pair in a dictionary.

SYNOPSIS

#include "drmaa2.h"

drmaa2_error drmaa2_dict_set(const drmaa2_dict dict, const char key, const char value)

DESCRIPTION

Stores a key / value pair in the given dictionary. Key and value strings are stored as pointers (no copies are made). If the dictionary already contains the key, the value pointer is removed. If the dictionary was created with a callback, the callback is called with NULL for the key. It is recommended that the user have to lookup if the key already exists before calling this function.

RETURN VALUES

In case of success DRMAA2_SUCCESS is returned otherwise the error code indcating the error is returned.

EXAMPLE

static void drmaa2_dict_string_free(char** key, char** value)
{
   drmaa2_string_free(key);
   drmaa2_string_free(value);
}

/* ... */

/* Create dictionary for job environment variables. */
drmaa2_dict dict = drmaa2_dict_create((drmaa2_dict_entryfree)drmaa2_dict_string_free);

if (dict == NULL) {
   printf("Error: Could not create a new dictionary.\n");
   return;
}

if (drmaa2_dict_set(dict, strdup("key"), strdup("value")) != DRMAA2_SUCCESS) {
   printf("Error: Could not set a new value in the dictionary.\n");
   return;
}

if (drmaa2_dict_del(dict, "key") != DRMAA2_SUCCESS) {
   printf("Error during deletion of the key value pair.");
}

/* Frees strings implicitly. */
drmaa2_dict_free(&dict);

SEE ALSO

drmaa2_dict_create(3), drmaa2_dict_free(3), drmaa2_dict_list(3), drmaa2_dict_has(3), drmaa2_dict_get(3), drmaa2_dict_del(3), drmaa2_dict_set(3)

AUTHOR

Copyright Univa Corporation 2013

  1. Univa Corporation
  2. October 2013
  3. drmaa2_dict_set(3)