473,796 Members | 2,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

memfrob and strfry ? OT

My string.h headers declares two functions I have been using called
memfrob and strfry. They are encryption types functions. My man pages say
they are standard to linux c and gnu c. They sure aren't in my C books.
Interesting functions by they're OT here but this raises to me a question.
If a function returns a pointer to a void and and as it's first parameter a
pointer to a void. Then should that function's first parameter accept a
string or pointer to char or any other data type since the parameter is
declared a void * ?

Bill
Jun 27 '08
35 5688
Richard Tobin wrote:
In article <Kl2Zj.25383$sX 5.23589@trnddc0 2>,
Bill Cunningham <no****@nspam.c omwrote:
My string.h headers declares two functions I have been using
called memfrob and strfry.

Laugh? I almost did.
I had Hunan chicken for lunch. Oh wait, that's stir-fry.

Brian
Jun 27 '08 #11
Default User wrote:
Richard Tobin wrote:
>In article <Kl2Zj.25383$sX 5.23589@trnddc0 2>,
Bill Cunningham <no****@nspam.c omwrote:
>> My string.h headers declares two functions I have been using
called memfrob and strfry.
Laugh? I almost did.

I had Hunan chicken for lunch. Oh wait, that's stir-fry.
Illegal. Can't use the hyphen here. Maybe stir_fry. :-)

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Jun 27 '08 #12
On 22 May 2008 at 3:35, Spiros Bousbouras wrote:
Of course on Linux a void * can hold even pointers to functions.
And more generally on POSIX. Actually, like so many things, this is
really Not A Problem in real life, but the clc regulars try to make it
into a problem so that they've got something to beef about.

Jun 27 '08 #13

"Keith Thompson" <ks***@mib.orgw rote in message
news:ln******** ****@nuthaus.mi b.org...
Ok, you want to learn about void*.

My advice: Forget about memfrob(). It's non-standard, and it doesn't
do anything particularly useful. Take a look at the various standard
mem*() functions: memcpy, memmove, memcmp, memchr, memset. To start
learning about them, read a book.
Here's what I have learned. Sec 5.4 pg 103. "...except for void *, to
assign a pointer of one type to a pointerr of another type withou a
cast." --k and r 2

Bill
Jun 27 '08 #14

"Spiros Bousbouras" <sp****@gmail.c omwrote in message
news:1467c554-96c0-48d3-8ee8-
Find some code which uses realloc() and study it.
That's the thing. I can't find any. I have about 64 bytes worth of
partition table data I can play with. According to what I've read this
function changes the size somehow.

Bill
Jun 27 '08 #15
Bill Cunningham wrote:
"Spiros Bousbouras" <sp****@gmail.c omwrote:
>Find some code which uses realloc() and study it.

That's the thing. I can't find any. I have about 64 bytes worth
of partition table data I can play with. According to what I've
read this function changes the size somehow.
#include <stdio.h>
#include <stdlib.h>

int main(void) {
void *t, *p, *pp;
size_t sz;

p = malloc(1);
for (sz = 2; sz < 100; sz++) {
pp = p;
if (t = realloc(p, sz)) p = t;
else {
printf("realloc failed at sz = %lu\n", (unsigned long)sz);
break;
}
printf("p was %p, is %p at sz = %lu\n",
pp, p, (unsigned long)sz);
}
return 0;
}

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #16
On Thu, 22 May 2008 21:51:35 +0000, Antoninus Twink wrote:
On 22 May 2008 at 3:35, Spiros Bousbouras wrote:
>Of course on Linux a void * can hold even pointers to functions.

And more generally on POSIX.
Wrong.
Jun 27 '08 #17
On 23 May 2008 at 16:47, Harald van Dijk wrote:
On Thu, 22 May 2008 21:51:35 +0000, Antoninus Twink wrote:
>On 22 May 2008 at 3:35, Spiros Bousbouras wrote:
>>Of course on Linux a void * can hold even pointers to functions.

And more generally on POSIX.

Wrong.
In that case, what do you do with the void * returned by dlsym()? Put it
on a shelf and admire its object-pointer-ness?

Jun 27 '08 #18
Harald van Dijk <tr*****@gmail. comwrites:
On Thu, 22 May 2008 21:51:35 +0000, Antoninus Twink wrote:
>On 22 May 2008 at 3:35, Spiros Bousbouras wrote:
>>Of course on Linux a void * can hold even pointers to functions.

And more generally on POSIX.

Wrong.
<OT>
See <http://www.opengroup.o rg/onlinepubs/009695399/functions/dlsym.html>,
particularly the rationale section.
</OT>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #19
In article <sl************ *******@nospam. invalid>,
Antoninus Twink <no****@nospam. invalidwrote:
>On 23 May 2008 at 16:47, Harald van Dijk wrote:
>On Thu, 22 May 2008 21:51:35 +0000, Antoninus Twink wrote:
>>On 22 May 2008 at 3:35, Spiros Bousbouras wrote:
Of course on Linux a void * can hold even pointers to functions.

And more generally on POSIX.

Wrong.

In that case, what do you do with the void * returned by dlsym()? Put it
on a shelf and admire its object-pointer-ness?
Is dlsym() POSIX?

I would assume that that is the picky point being made. And I would
assume that the answer is "no", FSVO "POSIX".

Probably some early draft release...

Jun 27 '08 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.