store.c 792 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * \file store.c
  3. *
  4. * \brief GIS Library - String storage functions.
  5. *
  6. * (C) 2001-2008 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public License
  9. * (>=v2). Read the file COPYING that comes with GRASS for details.
  10. *
  11. * \author GRASS GIS Development Team
  12. *
  13. * \date 1999-2008
  14. */
  15. #include <grass/gis.h>
  16. #include <string.h>
  17. /**
  18. * \brief Copy string to allocated memory.
  19. *
  20. * This routine allocates enough memory to hold the string <b>s</b>,
  21. * copies <b>s</b> to the allocated memory, and returns a pointer
  22. * to the allocated memory.
  23. *
  24. * \param[in] s string
  25. * \return pointer to newly allocated string
  26. */
  27. char *G_store(const char *s)
  28. {
  29. char *buf;
  30. buf = G_malloc(strlen(s) + 1);
  31. strcpy(buf, s);
  32. return buf;
  33. }