Memory Locations
http://www.ale.org/archive/ale/ale-1997-07/msg00118.html
For curiosity, you might try printing out the locations s1 and s2 in
the different versions by using printf's %p; you would likely see that
malloc, read-only strings, and stack-based arrays are all in distant
parts of memory.
Wednesday, August 31, 2005
Wednesday, August 24, 2005
Don't foreget when you define a pointer to define what it points to !
struct mystuct * s;
You can't say s->v1 = ... ; as you didn't say s equals what !!
you 've to say first s = new pointer, or s = return of a function ...
Don't forget to deallocate memory of a pointer received from a function return. (you didn't allocate that memory but it was allocated by the function you called)
Note That:
In a function, you have to return an allocated pointer (or edit a pointer passed to it as an argument) and you CANNOT return address of an object, cuz the object is locally defined and will be destroyed at the function termination, so the address will be pointing to garbage.
Also, it is NOT RECOMMENDED to pass solid objects through functions, especially if they are large size objects or structures as it is overhead on the stack
struct mystuct * s;
You can't say s->v1 = ... ; as you didn't say s equals what !!
you 've to say first s = new pointer, or s = return of a function ...
Don't forget to deallocate memory of a pointer received from a function return. (you didn't allocate that memory but it was allocated by the function you called)
Note That:
In a function, you have to return an allocated pointer (or edit a pointer passed to it as an argument) and you CANNOT return address of an object, cuz the object is locally defined and will be destroyed at the function termination, so the address will be pointing to garbage.
Also, it is NOT RECOMMENDED to pass solid objects through functions, especially if they are large size objects or structures as it is overhead on the stack
Wednesday, August 10, 2005
Thursday, August 04, 2005
Thursday, July 28, 2005
If a program requires a superuser privileges to do some job, "It is always best to give up the extra privilege when it is no longer needed, just in case the program has a latent bug that someone could exploit".
Richard Stevenes, Unix N/W Prog. V1
see line 11 page 666:
setuid(getuid()); /* don't need special permissions any more */
// it drops superuser privileges that was previuosly given to a normal user to be able to create a raw socket
Richard Stevenes, Unix N/W Prog. V1
see line 11 page 666:
setuid(getuid()); /* don't need special permissions any more */
// it drops superuser privileges that was previuosly given to a normal user to be able to create a raw socket
السلطات البريطانية لم توجه أي اتهام للنشار
http://www.misralarabia.com/article.asp?article=6359
طب اعتقلوه بناءاً على ايه؟
عشان شوية إشاعات في الجرايد؟
للدرجة دى من الاحتقار وهضم الحقوق تتعامل الدولة مع مواطنيها لإظهار مدى خنوعها للحكومة البريطانية ؟؟!!؟؟
فعلا : فى مصر، المواطن متهم حتى تثبت براءته
http://www.misralarabia.com/article.asp?article=6359
طب اعتقلوه بناءاً على ايه؟
عشان شوية إشاعات في الجرايد؟
للدرجة دى من الاحتقار وهضم الحقوق تتعامل الدولة مع مواطنيها لإظهار مدى خنوعها للحكومة البريطانية ؟؟!!؟؟
فعلا : فى مصر، المواطن متهم حتى تثبت براءته
Sunday, July 17, 2005
Struct vs. Union
if you defined:
struct s
{
int i;
char c;
}
when you define a variable of type s, a memory of size equals to the size of integer + the size of character will be reserved.
In contrasts, when you define:
union u
{
int i;
char c;
}
A variable of type u, results in the reservation of memory size of the max of integer and character, and this makes you are able to use the type u as either integer OR character.
summary:
struct = AND
unio = OR
if you defined:
struct s
{
int i;
char c;
}
when you define a variable of type s, a memory of size equals to the size of integer + the size of character will be reserved.
In contrasts, when you define:
union u
{
int i;
char c;
}
A variable of type u, results in the reservation of memory size of the max of integer and character, and this makes you are able to use the type u as either integer OR character.
summary:
struct = AND
unio = OR
Sunday, July 03, 2005
To read CHM help files under Linux
https://www.redhat.com/archives/fedora-list/2004-April/msg04652.html
https://www.redhat.com/archives/fedora-list/2004-April/msg04652.html
Tuesday, June 21, 2005
To update your object files:
Introduction to "make"
- if you changed the source file (.cpp) only, run:
make install - if you change header files, run:
make clobber install {removes all except source files} (or)
make clean install {removes only .o files} - also you can use rm
rm *.o
Introduction to "make"
Monday, June 20, 2005
to create a thread: you have to pass a name (address) of a function to pthread_create that is:
- static
- take void * as argument
- retuns void *
Subscribe to:
Posts (Atom)