Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.7 KiB

  1. /***********************************************************************
  2. * Microsoft (R) Windows (R) Resource Compiler
  3. *
  4. * Copyright (c) Microsoft Corporation. All rights reserved.
  5. *
  6. * File Comments:
  7. *
  8. *
  9. ***********************************************************************/
  10. #include "rc.h"
  11. /************************************************************************
  12. * PSTRDUP - Create a duplicate of string s and return a pointer to it.
  13. ************************************************************************/
  14. WCHAR *
  15. pstrdup(
  16. WCHAR *s
  17. )
  18. {
  19. return(wcscpy((WCHAR *)MyAlloc((wcslen(s) + 1) * sizeof(WCHAR)), s));
  20. }
  21. /************************************************************************
  22. ** pstrndup : copies n bytes from the string to a newly allocated
  23. ** near memory location.
  24. ************************************************************************/
  25. WCHAR *
  26. pstrndup(
  27. WCHAR *s,
  28. int n
  29. )
  30. {
  31. WCHAR *r;
  32. WCHAR *res;
  33. r = res = (WCHAR *) MyAlloc((n+1) * sizeof(WCHAR));
  34. if (res == NULL) {
  35. error(1002);
  36. return NULL;
  37. }
  38. __try {
  39. for (; n--; r++, s++) {
  40. *r = *s;
  41. }
  42. } __except(EXCEPTION_EXECUTE_HANDLER) {
  43. n++;
  44. while (n--) {
  45. *r++ = L'\0';
  46. }
  47. }
  48. *r = L'\0';
  49. return(res);
  50. }
  51. /************************************************************************
  52. ** strappend : appends src to the dst,
  53. ** returns a ptr in dst to the null terminator.
  54. ************************************************************************/
  55. WCHAR *
  56. strappend(
  57. register WCHAR *dst,
  58. register WCHAR *src
  59. )
  60. {
  61. while ((*dst++ = *src++) != 0);
  62. return(--dst);
  63. }