Re: Is MSDN wrong? or I made a mistake? about static member function

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



David Ching schrieb/wrote:

On the contrary, p1->x makes it easy to see p1 was allocated on the heap and needs to be deleted or otherwise memory managed. p1.x does not.

I don't understand. Given a pointer, there's no telling whether the object pointed to resides on the heap or on the stack.

struct S { int x; int y; };

S s;
S* p1 = &s;
int n = p1->x;
delete p1; // of course NOT
.



Relevant Pages

  • Re: [RFC][PATCH] Make ftrace able to trace function return
    ... I don't know much about the bottom stack of the tasks, ... +struct ftrace_return_data { ... static int ftrace_calc_offset ...
    (Linux-Kernel)
  • Re: more thread_info patches
    ... direct access of the stack field, where it's obvious it wants the stack ... struct switch_stack * childstack, *stack; ... void release_thread ... static int ptrace_getfpregs ...
    (Linux-Kernel)
  • [PATCH] x86: Simple changes to make traps_32.c and traps_64.c more similar
    ... asmlinkage void simd_coprocessor_error; ... +static int ignore_nmis; ... unsigned long *stack, unsigned long bp, ... const struct stacktrace_ops *ops, void *data) ...
    (Linux-Kernel)
  • [PATCH] fs: fcntl_setlease defies lease_init assumptions
    ... Björn Steinbrink also identified a slab leak in the same piece of code, caused by the fasync_helper call which will allocate a new slab every time because it uses the wrong structure (the one on the stack) when the a lease on that file already exists. ... int main ... goto out; ... int fcntl_setlease(unsigned int fd, struct file *filp, long arg) ...
    (Linux-Kernel)
  • Re: Mergesort algorithm for linked lists
    ... get rid of keeping the lengths of the runs on the stack. ... I still would like to know how to do it with a recursive routine, ... typedef struct linkedlist_t linkedlist_t; ... unsigned int level; ...
    (comp.lang.c)