Sponsored Content
Full Discussion: Deep copy of structure in C
Top Forums Programming Deep copy of structure in C Post 302906351 by cnamejj on Thursday 19th of June 2014 05:32:17 AM
Old 06-19-2014
There's a couple things that make it hard to just give you a suggested solution...

First, the structure you're talking about it generally not just one structure. It's a linked list of structures, each one describing one address info "chunk" of information. So do you just want to copy one link in the chain, or the whole thing?

Second, a "struct sockaddr" might seem like a simple, friendly little thing. But it's not. It's really a placeholder structure for another structure, usually either a "struct sockaddr_in" or a "struct sockaddr_in6". So copying it requires you to do more work than you would have to do for a static structure with a consistent format.

And third, which is really minor compared to the other two, is that even if you just one this one particular chain in the link, some of the fields are pointers. So the logic just has to allocate separate chunks of memory for the various pieces.

Maybe if you explain a bit more about what you're trying to do it would help? Obviously this has something to do with some sort of host/service lookup and scanning through the results. But that doesn't narrow things down very much.
This User Gave Thanks to cnamejj For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

any idea to copy directory structure

I want to copy the durectory structure having subdirectories in it ... would be greatful if anyone could let me know .. thanks in advance (6 Replies)
Discussion started by: myelvis
6 Replies

2. UNIX for Dummies Questions & Answers

copy files with directory structure

i have a text file as. /database/sp/NTR_Update_Imsi_List.sql /database/sp/NTR_Update_Imsi_Range_List.sql /database/sp/NTR_Vlr_Upload.sql /database/tables/StatsTables.sql /mib/ntr.mib /mib/ntr.v2.mib /scripts/operations/ntr/IMSITracer.ph /scripts/operations/ntr/IMSITracer.pl ... (3 Replies)
Discussion started by: adddy
3 Replies

3. Shell Programming and Scripting

Recursion to Copy a Directory structure

I have the below code to recurse through a given file path. I am able to go to the leaf level once recursively but traversing out is not possible as the required varaibles don't have the values on return. Both typeset and local don't work for my variable definitions. I have the o/p of the sample... (2 Replies)
Discussion started by: avrkiran
2 Replies

4. Shell Programming and Scripting

copy directory structure to a system on the network

I am trying to write a script which has to copy the directory structure from my system to another system on the network. But I dont want the files to be copied. I think I have to start with copying all subdirectories names in a directory to a system on the network. Here's the case: Source... (1 Reply)
Discussion started by: firefox211
1 Replies

5. Shell Programming and Scripting

Copy only folder structure ?

Hello, I am not sure how feasible is it, but trying to copy/create the folders from one box to another. I dont want to copy the content of folder otherwise it'd be too much of data.. The folder structure is quite complex (in deep hierarchy) and its a big effort manually .. Please... (5 Replies)
Discussion started by: navsha
5 Replies

6. Shell Programming and Scripting

Copy a file by creating folder structure in destination as in Souce

Hello, i am having a source directory which consist of multiple sub directories and my destination folder is a empty directory. if try to copy a file source->test->1.txt from source to destination test2 using the commaind. cp source/test/1.txt desti/ It will copy the 1.txt under desti... (1 Reply)
Discussion started by: tsaravanan
1 Replies

7. UNIX for Advanced & Expert Users

Copy Structure excluding some folders

Hi I want to copy the structure from one place to another. -> cd /hol/; -> find . -type d | cpio -pvdm /abc/cat; while copying the structure I want to exclude some directories like test1 and Test. I have read somewhere that this can be done with -prune option. Could anyone... (2 Replies)
Discussion started by: soumodeep123
2 Replies

8. Shell Programming and Scripting

Copy files from input file with dir structure

hi, I want to copy files from source directory based on input file (or output of previous command) and i want to have the SAME DIRECTORY STRUCTURE. Note that i will have other files and directories which i dont want to copy to destination. For example, dir source has following content:... (22 Replies)
Discussion started by: dragon.1431
22 Replies

9. Shell Programming and Scripting

Need to copy a directory structure from one server to another

Hello All, I have got a dev server and a production server will call it as D server and P server. I have a dir structure in my D server and i need to create the same dir structure in P server also using a shell script. If i do a find . in my D server, i am getting an o/p like :- . ./vio... (9 Replies)
Discussion started by: Renjesh
9 Replies

10. Shell Programming and Scripting

How to copy all structure folder create last day?

HI All, please help , i got same case . i want copy folder and directory create yesterday. for sample below : drwxr-xr-x 4 apps apps 33 Nov 23 04:00 xxxxxx@gmai.com drwxr-xr-x 4 apps apps 33 Nov 23 04:00 yyyyyyy@gmail.com drwxr-xr-x 4 apps apps 33 Nov 24 04:00... (2 Replies)
Discussion started by: fajar_3t3
2 Replies
CHAIN(3)						 MBK UTILITY STRUCTURE DEFINITIONS						  CHAIN(3)

NAME
chain - mbk lisp-like service structure DESCRIPTION
The chain is used for any purpose, when a list of pointer is required. The use of this structure is strongly recommanded, when such a need occurs. The declarations needed to work on chain are available in the header file "/labo/include/mut315.h", where '315' is the actual mbk version. The following C structure supports the description of the chain : typedef struct chain { struct chain *NEXT; void *DATA; } chain_list; NEXT Pointer to the next chain of the list. DATA Generic pointer used to point to any kind of object. Do not forget to cast the pointer back to its previous type when using this field. Remark : a specialized memory allocator has been built in order to create and free chain_lists, so absolutly avoid to create or free them an other way than through the access functions. SEE ALSO
mbk(1), addchain(3), freechain(3), delchain(3). BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory. We need your feedback to improve documentation and tools. ASIM
/LIP6 October 1, 1997 CHAIN(3)
All times are GMT -4. The time now is 05:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy