Re: strtok and strtok_r



In article <6JOdnW7Dx7Nq9XDbnZ2dnUVZ_gydnZ2d@xxxxxxxxxxx>,
Joe Wright <joewwright@xxxxxxxxxxx> wrote:

I don't want to check strlen for error. SIZE_MAX may well be valid.
Passing in a NULL should be a NOP in my view.

size_t strlen(const char *s) {
size_t r = 0;
if (s) while (*s++) ++r;
return r;
}

Then how will you distinguish between the string containing just
the terminating nul, and the null pointer?? strlen() is often
used to determine array indices; you don't want to be indexing
the NULL pointer (for one thing, the result of the indexing
might get you to a readable or writable memory location -- and yes,
there are real systems on which virtual addresses near 0 are
accessible.)
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
.



Relevant Pages

  • Re: [PATCH] [0/9] Use 64bit x86 machine check code for 32bit too
    ... warning: passing argument 2 of ‘strict_strtoull’ makes integer from pointer without a cast ...
    (Linux-Kernel)
  • Re: ByVal vs. ByRef
    ... But I still don't understand why I have to pass the TreeNode argument ByVal. ... I understand why passing it ByVal works. ... What is "the Value" of a reference variable? ... A "pointer" to the object. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Can a ref parameter be saved for later use?
    ... but in this scenario the 'passing back' will have to happen later. ... Form(ref string[] strLst) { ... Even in C/C++ it's a dangerous thing to capture a pointer to some data and save it for reuse later. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [opensuse] Promise SATA300-4TX kernel Module Fails to Build?
    ... passing argument 2 of ‘writeb’ makes pointer from integer without a cast ... missing whitespace after the macro name ...
    (SuSE)
  • Re: Critical section shared betwen dll and main program
    ... I am discussing the case of dynamic DLL ... loading and passing PCRITICAL_SECTION between old version of DLL ... and an executable which was build in newer environment. ... without passing a pointer to the kernel32.dll? ...
    (microsoft.public.win32.programmer.kernel)

Loading