]> granicus.if.org Git - python/commitdiff
Remove requirement for strdup() since it causes so many troubles for too many
authorFred Drake <fdrake@acm.org>
Thu, 9 Oct 1997 16:29:31 +0000 (16:29 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 9 Oct 1997 16:29:31 +0000 (16:29 +0000)
platforms.  Argh!

Modules/parsermodule.c

index 75b929beb087bc670da30d842e63dfac8313eb3e..9d624bca89482350fada526ce42822f59cb3a477 100644 (file)
@@ -26,9 +26,6 @@
                                        /* ISTERMINAL() / ISNONTERMINAL() */
 #include "compile.h"                   /* PyNode_Compile()               */
 
-#ifndef MS_WINDOWS
-char *strdup();
-#endif
 
 /*  String constants used to initialize module attributes.
  *
@@ -747,7 +744,10 @@ build_node_children(tuple, root, line_num)
            if (check_terminal_tuple(elem)) {
                PyObject *temp = PySequence_GetItem(elem, 1);
 
-               strn = strdup(PyString_AsString(temp));
+               /* check_terminal_tuple() already verified it's a string */
+               strn = (char *)malloc(PyString_GET_SIZE(temp) + 1);
+               if (strn != NULL)
+                   strcpy(strn, PyString_AS_STRING(temp));
                Py_XDECREF(temp);
 
                if (PyObject_Length(elem) == 3) {