Back to index

glibc  2.9
Functions
dl-origin.c File Reference
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <ldsodefs.h>
#include <dl-dst.h>

Go to the source code of this file.

Functions

const char * _dl_get_origin (void)

Function Documentation

const char* _dl_get_origin ( void  )

Definition at line 30 of file dl-origin.c.

{
  char *result = (char *) -1;
  /* We use the environment variable LD_ORIGIN_PATH.  If it is set make
     a copy and strip out trailing slashes.  */
  if (GLRO(dl_origin_path) != NULL)
    {
      size_t len = strlen (GLRO(dl_origin_path));
      result = (char *) malloc (len + 1);
      if (result == NULL)
       result = (char *) -1;
      else
       {
         char *cp = __mempcpy (result, GLRO(dl_origin_path), len);
         while (cp > result + 1 && cp[-1] == '/')
           --cp;
         *cp = '\0';
       }
    }

  return result;
}

Here is the caller graph for this function: