C++ Learning Community Forum
August 01, 2010, 02:36:13 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Passing an array to a struct.  (Read 127 times)
Joel
Coding from an Igloo
Jr. Nerd
***
Posts: 47


Linux coder


View Profile WWW
« on: March 05, 2010, 04:41:01 AM »

Hi all, been a while, I'm attempting new things:
Code
GeSHi (cpp):
typedef struct
{
    int *array;
} SomeStruct;
 
// later
 
int elems[] = {1,2,3,4,5};
 
SomeStruct ss;
ss.array = elems;
 
Created by GeSHI 1.0.7.18

Question is somehow memory leak in there or using a bad style of code? Thanks
Logged


* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM
* Ubuntu 9.04; Kernel 2.6.28-15-generic.
* lighttpd, php5, perl, eruby, python.
* geany, HTML & CSS & JavaScript, mono, gtk+, QT4, wxWidgets, bash, gcj.
* Coming soon: Kubuntu 9.10 or Dragora 1.1
C-Man
Does anyone even read this ?
Global Moderator
Dr. of C++ology
*****
Posts: 988



View Profile WWW
« Reply #1 on: March 05, 2010, 10:09:51 AM »

there is no allocation here , how can there be a leak...
elem is either on stack or in the data section depending on where you defined it
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!