Passing strings through registers to the PLI 
Author Message
 Passing strings through registers to the PLI

Excerpts from comp.lang.verilog: 8 6-May-99  Re: Passing strings by Mark Curry

Quote:
>field = malloc( strlen( field_temp ) );
>strcpy( field, field_temp );

This code would allocate one byte less than the required space because strlen()
returns the length of the string *without* including the terminating null byte.
The correct allocation would be:

  field = malloc(strlen(field_temp) + 1);

Incidentally, you can use strdup() to do both the allocate and copy steps at
once:

  field = strdup(field_temp);

Of course, you should check the return value to make sure you got what you
asked for!

Berend



Mon, 22 Oct 2001 03:00:00 GMT  
 Passing strings through registers to the PLI
Berand

Good point - thanks for the catch.  Could have been chasing that
around for a few days...

Regards,

Mark

Quote:

> Excerpts from comp.lang.verilog: 8 6-May-99  Re: Passing strings by Mark Curry
> >field = malloc( strlen( field_temp ) );
> >strcpy( field, field_temp );

> This code would allocate one byte less than the required space because strlen()
> returns the length of the string *without* including the terminating null byte.
> The correct allocation would be:

>   field = malloc(strlen(field_temp) + 1);

> Incidentally, you can use strdup() to do both the allocate and copy steps at
> once:

>   field = strdup(field_temp);

> Of course, you should check the return value to make sure you got what you
> asked for!

> Berend

--
Mark Curry          

Remove the animal from the domain to reply.


Tue, 23 Oct 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. How to pass a string from PLI to verilog/vcs

2. How to pass a string from PLI to verilog/vcs

3. PLI access to array register vectors

4. PLI beginner : how to access registers

5. modifying the register contents in a pli routine

6. Passing a memory to the PLI - how?

7. Error: Clock skew plus hold time of destination register exceeds register-to-register delay

8. Verilog - PLI passing args.

9. Error: Clock skew plus hold time of destination register exceeds register-to-register delay

10. gcc: passing register arguments to an assembly routine

11. PLI: How to change the string value in verilog from C

12. VisualAge PLI Enterprise vs. VisualAge PLI Personal

 

 
Powered by phpBB® Forum Software