Sponsored Content
Top Forums Programming How to allocate memory to a string in C? Post 302528390 by AAKhan on Tuesday 7th of June 2011 04:53:15 AM
Old 06-07-2011
hi
Here is the working code
/* This method takes String, Start Length and End Length as input parameters, sub string the string and returns it */

char* getsubstring(const char* urstr, size_t beginL, size_t len)
{
if (urstr == 0 || strlen(urstr) == 0 || strlen(urstr) < begin || strlen(urstr) < (beginL+len))
return 0;
return strndup(urstr + beginL, len);
}

Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix Help - allocate more memory to /tmp

Hi Guys I using Solaris 8 and I need to change the size of my /tmp file. Was wondering does anyone know how to do this. Thanks Carson (1 Reply)
Discussion started by: cmackin
1 Replies

2. Programming

how allocate virtual memory

Hi Folks can any body suggest how to allocate virtual memory any function for that (2 Replies)
Discussion started by: munnu
2 Replies

3. UNIX for Advanced & Expert Users

unable to allocate enough memory

On SunOS 5.8 I get an error when starting a large Java process with over 2Gb memory. Error occurred during initialization of VM Could not reserve enough space for object heap When stopping several other Java processes we can start this process. This seems to indicate that we don't have... (11 Replies)
Discussion started by: rein
11 Replies

4. UNIX for Advanced & Expert Users

How to allocate memory

Hi, I have 2 systems with same hardware and software. One system is giving me error "Error occurred during initialization of VM Could not reserve enough space for object " when I tried to increase JBoss App's heap size to 2GB while the other system is running fine without any issue. Is there... (5 Replies)
Discussion started by: ravi3553
5 Replies

5. UNIX for Advanced & Expert Users

Oracle how many memory allocate really

hi... i want to find oracle allocate how many memory really.. i execute this code to list memory on unix system : ps -eo pmem,args | sort -k 1 -r -n outputs ; %mem command 12.9|ora_smon_RTX 12.9|ora_s000_RTX 12.9|ora_reco_RTX 12.9|ora_qmnc_RTX... (2 Replies)
Discussion started by: utoptas
2 Replies

6. SuSE

shmget failed - cannot allocate memory

Hi, In my proj, one process was running for 2 days. after 2 days its throwing an error message "shmget failed cannot allocate memory". the same problem happened every time.i.e. i can reproduce the same issue if my process is running for every 2 days for a same operation.Within this 2 days there... (1 Reply)
Discussion started by: ManoharanMani
1 Replies

7. Linux

shmget failed - cannot allocate memory

Hi, In my proj, one process was running for 2 days. after 2 days its throwing an error message "shmget failed cannot allocate memory". the same problem happened every time.i.e. i can reproduce the same issue if my process is running for every 2 days for a same operation.Within this 2 days there... (1 Reply)
Discussion started by: ManoharanMani
1 Replies

8. Linux

shmget failed - cannot allocate memory

Hi, In my proj, one process was running for 2 days. after 2 days its throwing an error message "shmget failed cannot allocate memory". the same problem happened every time.i.e. i can reproduce the same issue if my process is running for every 2 days for a same operation.Within this 2 days there... (1 Reply)
Discussion started by: ManoharanMani
1 Replies

9. Solaris

unable to allocate enough memory

On SunOS 10 get an error when starting a large Java process with over 2Gb memory. Error occurred during initialization of VM Could not reserve enough space for object heap i have 32G memory !! , swap = 31G Please any advice !!! (3 Replies)
Discussion started by: moata_u
3 Replies

10. Programming

calloc fails: 'Cannot allocate memory'

Hi , experts. I work on Linux station (RedHat 5.7), regular user, but have root password. %> uname -a Linux ran1log06 2.6.18-238.1.1.el5 #1 SMP Tue Jan 4 13:32:19 EST 2011 x86_64 x86_64 x86_64 GNU/Linux %> cat /etc/issue Red Hat Enterprise Linux Client release 5.7 (Tikanga) Kernel \r on... (5 Replies)
Discussion started by: baruchgu
5 Replies
Data::GUID(3pm) 					User Contributed Perl Documentation					   Data::GUID(3pm)

NAME
Data::GUID - globally unique identifiers VERSION
version 0.046 SYNOPSIS
use Data::GUID; my $guid = Data::GUID->new; my $string = $guid->as_string; # or "$guid" my $other_guid = Data::GUID->from_string($string); if (($guid <=> $other_guid) == 0) { print "They're the same! "; } DESCRIPTION
Data::GUID provides a simple interface for generating and using globally unique identifiers. GETTING A NEW GUID
new my $guid = Data::GUID->new; This method returns a new globally unique identifier. GUIDS FROM EXISTING VALUES
These method returns a new Data::GUID object for the given GUID value. In all cases, these methods throw an exception if given invalid input. from_string my $guid = Data::GUID->from_string("B0470602-A64B-11DA-8632-93EBF1C0E05A"); from_hex # note that a hex guid is a guid string without hyphens and with a leading 0x my $guid = Data::GUID->from_hex("0xB0470602A64B11DA863293EBF1C0E05A"); from_base64 my $guid = Data::GUID->from_base64("sEcGAqZLEdqGMpPr8cDgWg=="); from_data_uuid This method returns a new Data::GUID object if given a Data::UUID value. Because Data::UUID values are not blessed and because Data::UUID provides no validation method, this method will only throw an exception if the given data is of the wrong size. IDENTIFYING GUIDS
string_guid_regex hex_guid_regex base64_guid_regex These methods return regex objects that match regex strings of the appropriate type. from_any_string my $string = get_string_from_ether; my $guid = Data::GUID->from_any_string($string); This method returns a Data::GUID object for the given string, trying all known string interpretations. An exception is thrown if the value is not a valid GUID string. best_guess my $value = get_value_from_ether; my $guid = Data::GUID->best_guess($value); This method returns a Data::GUID object for the given value, trying everything it can. It works like "from_any_string", but will also accept Data::UUID values. (In effect, this means that any sixteen byte value is acceptable.) GUIDS INTO STRINGS
These methods return various string representations of a GUID. as_string This method returns a "traditional" GUID/UUID string representation. This is five hexadecimal strings, delimited by hyphens. For example: B0470602-A64B-11DA-8632-93EBF1C0E05A This method is also used to stringify Data::GUID objects. as_hex This method returns a plain hexadecimal representation of the GUID, with a leading "0x". For example: 0xB0470602A64B11DA863293EBF1C0E05A as_base64 This method returns a base-64 string representation of the GUID. For example: sEcGAqZLEdqGMpPr8cDgWg== OTHER METHODS
compare_to_guid This method compares a GUID to another GUID and returns -1, 0, or 1, as do other comparison routines. as_binary This method returns the packed binary representation of the GUID. At present this method relies on Data::GUID's underlying use of Data::UUID. It is not guaranteed to continue to work the same way, or at all. Caveat invocator. IMPORTING
Data::GUID does not export any subroutines by default, but it provides a few routines which will be imported on request. These routines may be called as class methods, or may be imported to be called as subroutines. Calling them by fully qualified name is incorrect. use Data::GUID qw(guid); my $guid = guid; # OK my $guid = Data::GUID->guid; # OK my $guid = Data::GUID::guid; # NOT OK guid This routine returns a new Data::GUID object. guid_string This returns the string representation of a new GUID. guid_hex This returns the hex representation of a new GUID. guid_base64 This returns the base64 representation of a new GUID. guid_from_anything This returns the result of calling the "from_any_string" method. TODO
o add namespace support o remove dependency on wretched Data::UUID o make it work on 5.005 AUTHOR
Ricardo SIGNES, "<rjbs@cpan.org>" BUGS
Please report any bugs or feature requests to "bug-data-guid@rt.cpan.org", or through the web interface at <http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. COPYRIGHT
Copyright 2006 Ricardo Signes, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-01-18 Data::GUID(3pm)
All times are GMT -4. The time now is 09:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy