next up previous contents index
Next: Swap Functions Up: Utility Functions Previous: String Functions

Method String Functions

  The GRAPE method dispatcher is much faster if the method string contains a unique numeral code. On the other hand method strings are much more readable if not containing this code and strcmp will not work with the code part. The code will vary at every program start, so do not save enhanced method strings in files.

This is useful for method strings that are stored in variables or passed as function arguments. Because a constant string's method code can be found by hashing its address and constant function arguments will never change, there is no need to apply this functions on simple method call's arguments like that (constant arguments are easily identified by their leading """):

GRAPE (obj, "my-method")();
Of course the underlying concepts can change with new versions of GRAPE.
char *g_convert_method (char const * const method)
Allocate memory for the enhanced method string, calculate the method code, concatenate the passed string and return the resulting enhanced method string. You have to free the result using g_strfree. Already enhanced strings are simply g_strdupped, NULL will be returned unchanged.

If an unknown string is detected, the function generates a new number and stores a copy of method, so to save memory be careful not to pass random strings.

char *g_strip_method (char * const method)
Return the address of the first character of the readable string in method. Since the code is added at the head you get the original string. This function detects normal strings or NULL strings and returns the argument in this cases.



SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.