Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!samsung!spool.mu.edu!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.sources.wanted Subject: Re: What is strdup() supposed to do? Does anyone have a copy? Message-ID: <1991Feb22.020336.25209@athena.mit.edu> Date: 22 Feb 91 02:03:36 GMT References: <1991Feb17.045913.17126@sbcs.sunysb.edu> <16988@crdgw1.crd.ge.com> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 36 In article <16988@crdgw1.crd.ge.com>, volpe@camelback.crd.ge.com (Christopher R Volpe) writes: |> In article , |> fischer@iesd.auc.dk (Lars P. Fischer) writes: |> |>>>>>> dag@persoft.com (Daniel Glasser) writes: |> |> |> |>Daniel>Nit #2: You should simplify your expression in the "malloc()", |> that is, |> |>Daniel> sizeof(char) * strlen(foo) + sizeof(char) |> |>Daniel> could be written |> |>Daniel> sizeof(char) * (strlen(foo) + 1) |> ^ |> |-This paren isn't closed, and |> may be causing much of the confusion. Here is what appeared in the Daniel Glasser's posting: >Nit #2: You should simplify your expression in the "malloc()", that is, > sizeof(char) * strlen(foo) + sizeof(char) > could be written > sizeof(char) * (strlen(foo) + 1) Here's the last line, with parentheses counted in the style of lisp paren counting (add one for each open parenthesis, subtract one for each closing parenthesis, and hope you end up with 0 :-): sizeof(char) * (strlen(foo) + 1) 1 0 1 2 1 0 It sure looks to me like the paren was closed. Someone's confused, but I don't think it's Daniel Glasser or the people who have agreed with him. -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710