05-20-2013
Quote:
Originally Posted by
migurus
I have no system available to test your code.
For your Q.1 I'd use "struct numlist *numbers" in main and change make_list to return pointer to structure.
The Q.2 is not clear to me, what does not look right to you?
Q.1: ok, thanks. y
Q.2: Inside of the function make_list() i declare a struct num_list tmp, but i don't allocate any memory. I allocate memory to the list, depending how much elements it will contain. Will the struct num_list tmp have enough memory to store the list, no matter how much elements the list contains? (The question reveals that memory allocation is not always clear to me).
10 More Discussions You Might Find Interesting
1. IP Networking
How can change udp lenght?
Hello.
I have FreeBsd 4.7 and i want to change udp datagramm lenght.
Where it can be? What i must do? I can rebuild my core but it is not good for me.
Thanks! (4 Replies)
Discussion started by: Vvlad
4 Replies
2. UNIX for Dummies Questions & Answers
How to remove files with zero lenght with one or more commands from the same directory?
Thanks. (2 Replies)
Discussion started by: GNMIKE
2 Replies
3. Shell Programming and Scripting
Hi All,
I have a pipe separated flat file.But there is often some problem with the records.So is it possible to convert the '|' separated file into a fixed length file by means of some script.
The file has 11 columns which means 10 pipes.Your help is appreciated.
i'm using Sun OS Version... (2 Replies)
Discussion started by: kumarsaravana_s
2 Replies
4. Programming
I am facing a strange error while creating posix threads:
Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output.
Snippet 1
This works:
--------------
int *threadids;
threadids = (int *) malloc (num_threads * sizeof(int));
... (4 Replies)
Discussion started by: kmehta
4 Replies
5. Shell Programming and Scripting
I'm not familiar with find.
If i use find in a certain directory i want it to show based on hierarchy.
find . type d
fol1
fol1/subfol1
fol1/subfol1/subfol1
fol2
fol2/subfol2
i want it to show like this
fol1/subfol1/subfol1
fol1/subfol1
fol1
fol2/subfol2
fol2
do i need to use... (5 Replies)
Discussion started by: ryandegreat25
5 Replies
6. UNIX for Advanced & Expert Users
Hi
I want to know the maximum length of user name under NIS? I tried googling but it didnt help :(. If there is any command to find out this please let me know. I know on unix user name should be 8 characters long but just i want to know if i can have 9 letter user under mapped under NIS. (1 Reply)
Discussion started by: zedex
1 Replies
7. Shell Programming and Scripting
Using the KSH, write a shell script called display_by_length, which takes an absolute pathname to a directory and displays all ordinary files in the directory ordered by their length; for each file listed, display the name of the file and its length - nothing else. Extend this script to take an... (1 Reply)
Discussion started by: babuda0059
1 Replies
8. Shell Programming and Scripting
I made menu script for users so they can run other script without going in shell just from menu.
But i must control their input.
These are criteria:
Input must have 4 signs
First two signs are always lower case letters
Input shall not have some special signs just letters and numbers
... (1 Reply)
Discussion started by: waso
1 Replies
9. UNIX for Advanced & Expert Users
actually i am trying to find the lenght of fixed width file record reading from teradata db but its not working can u guys help me out?
code which i wrote---
colmn_lngth=`cat $RPT_FILE | awk -F~ '{print $1}'`
rm $RPT_FILE
while read line
do
result=`echo $line | wc -m`
... (4 Replies)
Discussion started by: Seshendranath
4 Replies
10. Shell Programming and Scripting
Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help.
pesudo code
if == ENDSINFIVEINTS ]]; then
do... (4 Replies)
Discussion started by: briandanielz
4 Replies
t_alloc(3) Library Functions Manual t_alloc(3)
NAME
t_alloc() - allocate transport function library structure
SYNOPSIS
-- or --
DESCRIPTION
The function dynamically allocates memory for the various transport function argument structures as specified below. This function will
allocate memory for the specified structure and will also allocate memory for buffers referenced by the structure.
The structure to allocate is specified by struct_type and must be one of the following:
T_BIND struct t_bind
T_CALL struct t_call
T_DIS struct t_discon
T_INFO struct t_info
T_OPTMGMT struct t_optmgmt
T_UDERROR struct t_uderr
T_UNITDATA struct t_unitdata
where each of these structures may subsequently be used as an argument to one or more transport functions.
Each of the above structures, except T_INFO, contains at least one field of type For each field of this type, the user may specify that the
buffer for that field should be allocated as well. The length of the buffer allocated will be equal to or greater than the appropriate
size returned in the info argument of or The relevant fields of the info argument are described in the following list. The fields argument
specifies which buffer to allocate, where the argument is the bitwise-OR of any of the following:
The addr field of the or structures.
The opt field of the or structures.
The udata field of the or structures.
All relevant fields of the given structure.
Fields which are not supported by e transport provider specified by fd will not be allocated (info values are <= 0).
For each field specified in fields, will allocate memory for the buffer associated with the field, and initialize the len field to zero and
the buf pointer and maxlen field accordingly. Since the length of the buffer allocated will be based on the same size information that is
returned to the user on or fd must refer to the transport endpoint through which the newly allocated structure will be passed. In this way
the appropriate size information can be accessed. If the size value associated with any specified field is -1 or -2 ( see t_open(3) or
t_getinfo(3)), will be unable to determine the size of the buffer to allocate and will fail, setting to and to For any field not specified
in fields, buf will be set to a null pointer and maxlen will be set to zero.
Use of to allocate structures will help ensure the compatibility of user programs with future releases of the transport interface func-
tions.
Valid States
All, apart from
Fork Safety
is not fork-safe.
RETURN VALUE
Upon successful completion, returns a pointer to the newly allocated structure. On failure, a null pointer is returned.
ERRORS
On failure, is set to one of the following:
fd, the specified endpoint identifier, does not refer to a transport endpoint.
A system error has occurred during execution of this function.
(XTI only) This error indicates that a communication problem has been detected
between XTI and the transport provider for which there is no suitable XTI
Unsupported struct_type requested. This can include a request for a structure type which is inconsistent with the transport provider
type specified, that is, connection-oriented or connectionless.
SEE ALSO
t_free(3), t_getinfo(3), t_open(3), thread_safety(5).
STANDARDS CONFORMANCE
t_alloc(3)